MrPickle Posted October 22, 2008 Share Posted October 22, 2008 I don't know why, but my function is printing itself ??? Not much more to say so here's my code: <?php include "Highlight.php"; //http://rafb.net/paste/highlight.phps function PrintCpp($path) { $file = fopen($path, 'r'); $data = ""; while(!feof($file)) $data .= fgets($file, 4096); echo syntax_highlight($data, "C++"); } ?> It is printing the included file but not all of it, I can't work out where it's printing from but I think it's from the 9th line in keyword_replace Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/ Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 We'd need to see the included file. EDIT: Just saw the link, nvm. I'll check it out. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672229 Share on other sites More sharing options...
MrPickle Posted October 22, 2008 Author Share Posted October 22, 2008 Doing an error check it's saying: Fatal error: Call to undefined function syntax_highlight() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Site\Parse.php on line 8 It's saying that it's undefined when the function is actually highlighting itself?! Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672236 Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 I think I know what the problem is. short_tag_open is off on your server (which is just fine. Hell, it's better off that way), and the person who wrote that highlighter clearly didn't plan on releasing it because he used short tags (which is a big no-no). Change <? to <?php in the Highlight.php file. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672238 Share on other sites More sharing options...
MrPickle Posted October 22, 2008 Author Share Posted October 22, 2008 Oh wow, such a trivial thing caused such a big error. May I ask why not adding the 'php' bit to the tag causes this to happen? Thank you, btw. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672243 Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 Sure, I'd be glad to explain. The standard opening tag is, as you know, is <?php. A while back, they introduced a 'short tag' to make PHP programming easier (it actually made it harder though). Since this option can be turned off (and it is by default), it's STRONGLY discouraged to use the short tag family (<? and <?=) in any modern scripts that will be distributed or possibly used on different servers. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672246 Share on other sites More sharing options...
MrPickle Posted October 22, 2008 Author Share Posted October 22, 2008 Great, thanks. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672248 Share on other sites More sharing options...
Barand Posted October 22, 2008 Share Posted October 22, 2008 Also, XML hijacked <? as its opening tag Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672264 Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 Also, XML hijacked <? as its opening tag Yup. Link to comment https://forums.phpfreaks.com/topic/129655-solved-function-echoing-itself/#findComment-672265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.