Jump to content

function name must be a string? what function?


dhmyers82

Recommended Posts

I keep getting the following error:

Fatal error: Function name must be a string in /home/dmyers53/public_html/Projects/Chisese_Zodiac_for_loop.php on line 34

I dont have a function named, where am I going wrong?

<body>
<img src="images/rat.jpg"></img><!--test the source. WORKS-->
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

echo "<p>This line works</p>\n";//yes it does
$zodiacPictures = array(
	"images/rat.jpg",
	"images/ox.jpg",
	"images/tiger.jpg",
	"images/rabbit.jpg",
	"images/dragon.jpg",
	"images/snake.jpg",
	"images/horse.jpg",
	"images/sheep.jpg",
	"images/monkey.jpg",
	"images/rooster.jpg",
	"images/dog.jpg",
	"images/pig.jpg");
	
for ($imgCounter = 0; $imgCounter <= 12; ++$imgCounter){
echo '<img src="' . $zodiacPictures($imgCounter) . '"></img>';// line 34
}
?>
</body>
</html>

This function

$zodiacPictures($imgCounter)

You need [..] for array indexes.

(..) is for functions

 

[edit] Using foreach() would be easier

foreach ($zodiacPictures as $src){
    echo '<img src="' . $src . '" />';
}

and there are no </img> tags

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.