mercredi 23 novembre 2016

Including a PHP file within PHP

I have a website which is running a PHP if statement to show content based on the type of file attached, i.e. Jpg, Txt, MP4.

So my code for showing TXT files is:

if($post_attachment == 'txt'){$display_attachment = "

        <div class=\"sectionDivide\"></div>
        <div class=\"section\">
            <div class=\"articleAttachment\">
                include(\"../a/files/attachments/$post_year/$post_month/$post_id.$post_attachment\");
            </div>
        </div>

    ";}

The problem is that it's not displaying the content of the TXT file, but instead showing the line include("../a/files/attachments/2016/11/161123095119.txt"); in my web page.

How can I get it to display the content of the text file where I echo out $display_attachment?

Aucun commentaire:

Enregistrer un commentaire