Forum Moderators: coopster
echo("example");
echo "example";
Now since echo [php.net]() can take more than one argument, you can echo multiple strings out at once:
echo("one","two","three","four","five");
But since this is a construct, we can also write this like this:
echo "one", "two", "three" ,"four" ,"five";
removing the parenthesis as they are not needed. As for include, you can only include one file at a time, however it is still a language construct therefore the parenthesis are still not required.
include "file.php";
I believe that there are a few language constructs that require the parenthesis but I don't know off the top of my head. Anyway, I hope that answers your question.
Here is the explode script my friend uses, hopefully it will help someone out. Again I'm dealing with the AJAX HTTP query issue (HTTP query (?query_property=query_value)) not being passed to PHP and it's the AJAX script I've been using. Anyway you guys probably want explosions so here you go (and don't ask me how it works!) ;)
- John
//If other scripts are requested, load them toooooooo
if (!empty($_GET)){
$i=null;
foreach($_GET as $key=>$val){
if(!empty($i)){
$i .= ',';
}
$i .= $key;
}
if($i === 'all') {
$i = 'dhtml,sounds,chat,fscroll,pkeys,target,prompt';
}
$opts = explode(',',$i);
doStart();
foreach($opts as $name){
loadScript($name);
}
loadScript('focus');
// doClose();
}
JAB_Creations, what is happening here is certain values are being selected or requested via GET in the browser and here in your server-side script the programmer is collecting those values, accumulating them in a comma-separated list. Once the collection is completed, the list is exploded [php.net] into an array for further processing via a foreach loop which runs a "loadScript" function. The "loadScript" presumably includes [php.net] a specified file based on the selections passed.
You can only include one file via the include statement, but you can certainly loop through an array of specified files including them one-by-one consecutively.