Page 1 of 1
string error
Posted: Wed Nov 10, 2010 12:29 am
by phpBrandNew
I have the following code and I got the following error :
<?php
$myswfarray("A.swf", "B.swf", "C.swf");
$randomswf = array_rand(array_flip($myswfarray), 1);
echo "show $randomswf ";
?>
Fatal error: Function name must be a string in C:\xampp\htdocs\loadswf.php on line 2
Could someone point out where should I change for the function name and how ?
Re: string error
Posted: Wed Nov 10, 2010 12:49 am
by McInfo
PHP thinks "$myswfarray" is a variable that should contain a function name because it is followed by "(". Because $myswfarray is not set, it is not a string, hence the error.
The real problem is that an assignment operator is missing.
Code: Select all
$myswf = array("A.swf", "B.swf", "C.swf");
Re: string error
Posted: Wed Nov 10, 2010 7:23 am
by phpBrandNew
I change as following, I have the message show swf in random manner. I put the swf with php file, but swf is not loaded, please advise.
<?php
$myswf=array("A.swf", "B.swf", "C.swf");
$randomswf = array_rand(array_flip($myswf), 1);
echo "show $randomswf ";
?>
Re: string error
Posted: Wed Nov 10, 2010 1:09 pm
by McInfo
The Flash is not loaded because the output from your script (a string, "show A.swf ") has no meaning to any of the actors involved in transporting data from the server to the user. It is simply a string of characters.
I am not sure what you wish to happen, but perhaps it would be suitable to replace
with
Code: Select all
header('Content-Type: application/x-shockwave-flash');
readfile($randomswf);
Re: string error
Posted: Wed Nov 10, 2010 8:48 pm
by phpBrandNew
OK, it is just what I want. Thanks.