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 ?
string error
Moderator: General Moderators
Re: string error
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.
The real problem is that an assignment operator is missing.
Code: Select all
$myswf = array("A.swf", "B.swf", "C.swf");-
phpBrandNew
- Forum Commoner
- Posts: 36
- Joined: Thu Sep 02, 2010 12:51 am
Re: string error
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 ";
?>
<?php
$myswf=array("A.swf", "B.swf", "C.swf");
$randomswf = array_rand(array_flip($myswf), 1);
echo "show $randomswf ";
?>
Re: string error
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
I am not sure what you wish to happen, but perhaps it would be suitable to replace
Code: Select all
echo "show $randomswf ";Code: Select all
header('Content-Type: application/x-shockwave-flash');
readfile($randomswf);-
phpBrandNew
- Forum Commoner
- Posts: 36
- Joined: Thu Sep 02, 2010 12:51 am
Re: string error
OK, it is just what I want. Thanks.