You can't include code within variable declarations. Not only that, but you wouldn't want to. Would make your code quite messy and not very well maintainable.
The proper way to do it is using the ternary operator:
http://au2.php.net/manual/en/language.o ... arison.php
You may want to read about strings and concatenation too..
For your example, it'd be best off written like:
Code: Select all
$mydomain = "http://localhost/";
$table = "<table width=75% cellpadding=2 cellspacing=1 border=0><tr><td valign=top>"
."<img src=".(eregi($mydomain, $_SERVERї"HTTP_REFERER"]) ? "../" : "")."images/image1.gif"
."</td></tr></table>";
I should also note that eregi() isn't a good function to use if you're not using regexps. If you just want to find out if a string occurs in a string, the manual says strpos() is the fastest and less memory intensive way. So i'd change it with strpos($_SERVER['HTTP_REFERER'], $mydomain) instead.