To show RAW data from my database without any formating or fields info I use this: <?php renderSingleListingItemRaw($listingID, "data") ?> PHP: So what I want to do is use an include statement that will output this data and from that include a file from another folder location, such as the file below. <?php include './folder/fileA.html' ?> PHP: Is this possible? E.G. <?php include './folder/renderSingleListingItemRaw($listingID, "data").html' ?> PHP: Which doesn't work!! Thanks Ian Thanks Ian
I've managed to do with the following, it's not what i fully wanted and means renaming a few files, but it does the job. <?php include './folder/' . $listingID . '.html' ?> PHP: Ian
could NOT have worked because you forgot the (); hence if you want to test try syntax like <?php include ('folder/fileA.html'); ?> unless you KNOW why you want to include a html file and unless you have no other choice - I recommend you call the file to include some different file extension - may be fileA.tpl why ? if EVER you want to parse HTML files for PHP-SSI includes - then you surely want to include text module used for your include(). re your paths in include() always keep in mind that - my experience - include() does NOT accept absolute server paths like /folder/subfolder/file.tpl but works fine with: 1. relative paths 2. full URLs ( starting http://...)
Have you tried something like this? <?php include './folder/'.renderSingleListingItemRaw($listingID, "data").'.html' ?> PHP: Assuming the function returns only a valid filename, and that file actually exists, this should work.
From the PHP manual: Because include() is a special language construct, parentheses are not needed around its argument.
The php manual contains this caution about using include: In my own work, I would never include an html file. I would open the file and read it into an array, do whatever my script needed to do with the file contents, and then continue with my script -- whether displaying something to the screen or doing something else.
Now you can't. The function above opens,reads and outputs the file info, which are not includeable. You can only include files, not file content. Peace,
Thanks for all the feedback etc.. Am I right in thinking that some of you are saying you 'SHOULD NOT' use a .html as an include for security issues??? eg <?php include './folder/fileA.html' ?> PHP: If so why...?
It's fine to include an html file from your own server. You shouldn't include files that aren't trusted because they could contain malicious code. readfile() would be better in that case.