jump to last post 1-4 of 4 discussions (4 posts)

Simple PHP Include of a text file?

  1. NickSimpson profile image60
    NickSimpsonposted 7 years ago

    Simple PHP Include of a text file?

    I am looking for a simple php code/script I can use to include a text file.  I want to be able to add the code to many webpages and the script would pull links/anchortext from a txt file on a web server off site.  I don't think that this should be too tricky, but I am not a coder.

    Thanks in advance,

    Nick

  2. ineveryoneheart profile image55
    ineveryoneheartposted 7 years ago

    You need to put your txt file by this way
    include("file.txt");

  3. dabeaner profile image55
    dabeanerposted 7 years ago

    Your file with the "include" has to be a php file and not an htm file.
    ineveryoneheart's comment is correct, but there is a little bit more to it than that.

    If you want to code, you have to learn to code.
    There are introductory articles on the internet, and "Dummy" and "Idiot" books that cover the basics.

  4. profile image45
    guru24posted 7 years ago

    Hi,

    There are two kinds of language construct in php for including file.
    include and require

    There is basic difference in both of them is how handle they errors and script execution.

    Using "include" - will give warning in case file is not present in path or not permission to read and php script will continue .

    Using "require" - will halt the system and stop execution in case file is not present in path or not permission to read.

    and their sister method include_once "dir/filepath/filename.ext"
    and require_once "dir/filepath/filename.ext"

    include_once and require_once is best at point - when you are including multiple file and not remember any file is already including or not then _once will remember if file is included already then it skip for duplicate include.

    If your including file is not so important to include in page then you can go with "include" or include_once

    or in other case your including file is most important to process further page process then do use
    require or require_once

    More Ref:
    http://php.net/manual/en/function.include.php

    http://www.php.net/manual/en/function.require.php

    If still you feel difficulty to implement, just mail me
    i will do free for you.

    Enjoying ..

 
working