Is it possible to include a file that contains a string value (in this case a comma delimited list of values) as an argument to a function?
For example:
include.php
<?php
'value1,value2,value3'
?>
function.php
<?php
function test($string)
{
echo $string;
}
test(include 'include.php');
?>
I’ve tried this and it doesn’t work, but is there a way to do what I am trying?
Does
include.phphave to be a PHP file?If not, make it an ordinary text file (eliminating the
<?phpand?>tags), and use:That will just read the contents of
include.txtas a string, and of course you can then do whatever you’d like.Otherwise, using
includeactually executes the PHP in the file, so you could makeinclude.phpcontain:And then use: