Jump to content

[SOLVED] Function echoing itself


MrPickle

Recommended Posts

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

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?!

 

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.

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.

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.