I have seen some sites with the php color codes sorta like what the forum has. Is there a way to have that for a website?Yes, these two functions help.
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.highlight-file.php">http://www.php.net/manual/en/function.h ... t-file.php</a><!-- m -->
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.highlight-string.phpthanks">http://www.php.net/manual/en/function.h ... .phpthanks</a><!-- m --> man, do I have to edit httpd?noif the httpd is setup correctly you can just do file.phps
notice the phps on the end? that will make it print in color. doesn't work if the server is setup in cgi mode.ya, thanks guys I got it working
link removed by scoutt
is there a way that I could have just some php get highlighted, I want to do it for my php snippet page at my site and when I put it in text areas it hides that code, as if it is being used.TAKE THAT SCRIPT DOWN IMMEDIATELY!
Unless you want an insecure system, that is.
It took me 3 sec to get your MySQL user/password!Rydberg is correct, you can see any php code if you do that.
all I had to do was put this file in the url "webvars.inc.php" and saw everything in it.
if you do what I suggested you can get by this. but that means you need to create another file but have it have the .phps extension.Hmm I see you have started a new thread here, yet you haven't addressed this problem.. Your auth info has been exposed, and I suggest you take that script offline, as well as change your password.
I also noticed this in your index.php:
"// copyright by <!-- w --><a class="postlink" href="http://www.razorart.com">www.razorart.com</a><!-- w -->"
Know what that means? I know one of the people behind that site, since 4 years. I suggest you at least remove the evidence when you steal code.. Well, of course, you could have permission, what the heck do I know.
On the other hand, RazorArt is nowadays shut down, so I guess it's not a big deal anyway. Their logo must be the most commonly ripped logo on the net today! I've seen it on so many other things.
Excuse me for doing so, but I got pretty curious, about just how far this could be taken.. Actually with some creative guesses of possible filenames, I actually found my way to your Fusion users file, open for the public, usernames and passwords and all.. MD5 encrypted though, it seems No worries, I have no malicious intentions. Anyway, can we make the point any clearer? I know, the code from razorart was a javascript image fade, and i didnt take any of his logos I dont rip stuff from people.
FYI ^
And what I was trying to say about the post is I want a php snippet highlighted but on the file page. not viewing the source of it.
ex:
<?php include ......;?> <- have that glow (highlight)
or am I going to have to use font tags? hahahhaOh I know you didn't rip the logo.. That was just a 'BTW'.
Oh, and I kind of answered that question already. highlight_string().
<?php
$code = "<?php echo 'hello world'; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
This demonstrates two ways to use it. The first will colour the code, and print, while the second will colour the code and then return a string.
I wouldn't call <?php include($file); ?> or <?php phpinfo(); ?> "code snippets"... Well technically, they are, but still.. Make one 'snippet' for every function there is, why don't you are you going to even try the .phps way. that will work just fine as you have to make a file to do that and it wouldn't lead to prblems like you had before. but if it is code you want like I do on my site then what Rydberg suggested is the only way. it is all up to youThanks man! I am going to try the highlight string. I will check that out.
Scoutt what do you mean by the *.phps do I name the file that or rename the source.php with the extension *.phps?
Yes, I was going to try that way, just jumped ahead and thoguht of another idea.well for any file you want to color code you will need to make a copy and rename it to .phps
but more dynamic will be the highlight string way.ok, I get the phps extension way now. When I go and use the php highlight function, part of the code gets "processed" and part just displays text.
I made a demo page of the highlight function.
demo page for highlight (<!-- m --><a class="postlink" href="http://www.rksunderground.com/highlight.php">http://www.rksunderground.com/highlight.php</a><!-- m -->)
well you get a parse error at that page, haha
"; highlight_string($code); $colourcode = highlight_string($code, true); echo $colourcode; ?>
I am at school and I am using Dreamweaver and that is the code snippet that gets displayed on the copy locally but when I look at it remotely it is a error.is that the full line?
php color will color everything between the <? ?> tags, anything outside of that will be black like regular html text.
you can change this if you want with a ini_set() function. you can change all of the colors.This is the code I am using.
<?php
$code = "<? include "filename"; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
When I look at it in Dreamweaver its is where it ends.
";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
its almost as if it is just recongizing include and not the rest.you can't do it that way.
you have to stick the code in a variable inside that file and then highlight it. you can't stick an include in a variable like that.
$code = "<? echo\" some code here\"; ?>";
echo highlight_string($code, true);<?php
$code = "<? include \"filename\"; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
you didn't escape the quotes... And this code will print the coloured code twice, just so you know.. I was just demonstrating two different ways to use the highlight_string() function.
Hmm, scoutt, I don't think he's trying to include a file there, I would guess it's just some sample code, just to test the highlight_string() function..ok scoutt, this is what I have now for code, would this be right?
<?php
$code = "<?php echo '<?php echo $_SERVER['REMOTE_ADDR']; ?> '; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
I put the echo variable in side the actual echo that will display it on the page.
And Rydberg, what do you mean by two methods of highlighting?I'm talking about two ways to use that function, highlight_string(). Notice the parameter count in my examples.
highlight_string($string) will highlight the code in $string AND print it to the browser.
$newstring = highlight_string($string, true) will highlight the code in $string BUT send the results back as a string, and NOT print it to the browser. This can be useful, if you'd like to edit it in some way.
That code you have there is pretty messed up.. I just think scoutt misunderstood, but im not sure. Try my last example, and it'll work.ok, I get what you meant now. By your last example code do you mean this one:
<?php
$code = "<?php echo 'hello world'; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
would the code be placed in where "hello world" is? Ex. I would use a like include or another php code there. The code above is the code I used. Is that what you meant by the last example?I don't think he was trying to include either but the code didn't think that.
<?php
$code = "<? echo\" some code here\"; ?>";
highlight_string($code);
?>
that code works just fine. that is how I do it as well.
$code = "<?php echo '<?php echo $_SERVER['REMOTE_ADDR']; ?> '; ?>";
that will print but it will look funny. you don't need the extra <? tags in there.
remember, the highlight_string will highlight anything in the variable, you don't need to do anything special apart from what I did here.thanks I got it working with a include and a show php info. Is it possible to have multiple lines of code in there? I tried it with a last modified script and a couple others and I got errors.
<table width="260">
<tr>
<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime("filename.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?>" highlight_string($code); ?></center></td>
</tr>
</table>because you forgot a semi-colon at teh end of the code variable.
<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime("filename.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?>"; highlight_string($code); ?></center></td>that, and that you again didn't escape the quotes in the string.what quotes do you mean?<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime(\"filename.php\");
print(\"Last Modified \");
print(date(\"m/j/y h:i\", $last_modified));
?>"; highlight_string($code); ?></center></td>I found a highlight function that used a external txt file and you put the code in there and I cant remember where I found it. It was like highlight implode then a link to the txt file. Does anyone know what I am talking about?thats easy.
<?php
$text = file("text.txt");
$string = '';
for ($i=0; $i<count($text); $i++){
$string .= $text[$i];
}
highlight_string($string);
?>
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.highlight-file.php">http://www.php.net/manual/en/function.h ... t-file.php</a><!-- m -->
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.highlight-string.phpthanks">http://www.php.net/manual/en/function.h ... .phpthanks</a><!-- m --> man, do I have to edit httpd?noif the httpd is setup correctly you can just do file.phps
notice the phps on the end? that will make it print in color. doesn't work if the server is setup in cgi mode.ya, thanks guys I got it working
link removed by scoutt
is there a way that I could have just some php get highlighted, I want to do it for my php snippet page at my site and when I put it in text areas it hides that code, as if it is being used.TAKE THAT SCRIPT DOWN IMMEDIATELY!
Unless you want an insecure system, that is.
It took me 3 sec to get your MySQL user/password!Rydberg is correct, you can see any php code if you do that.
all I had to do was put this file in the url "webvars.inc.php" and saw everything in it.
if you do what I suggested you can get by this. but that means you need to create another file but have it have the .phps extension.Hmm I see you have started a new thread here, yet you haven't addressed this problem.. Your auth info has been exposed, and I suggest you take that script offline, as well as change your password.
I also noticed this in your index.php:
"// copyright by <!-- w --><a class="postlink" href="http://www.razorart.com">www.razorart.com</a><!-- w -->"
Know what that means? I know one of the people behind that site, since 4 years. I suggest you at least remove the evidence when you steal code.. Well, of course, you could have permission, what the heck do I know.
On the other hand, RazorArt is nowadays shut down, so I guess it's not a big deal anyway. Their logo must be the most commonly ripped logo on the net today! I've seen it on so many other things.
Excuse me for doing so, but I got pretty curious, about just how far this could be taken.. Actually with some creative guesses of possible filenames, I actually found my way to your Fusion users file, open for the public, usernames and passwords and all.. MD5 encrypted though, it seems No worries, I have no malicious intentions. Anyway, can we make the point any clearer? I know, the code from razorart was a javascript image fade, and i didnt take any of his logos I dont rip stuff from people.
FYI ^
And what I was trying to say about the post is I want a php snippet highlighted but on the file page. not viewing the source of it.
ex:
<?php include ......;?> <- have that glow (highlight)
or am I going to have to use font tags? hahahhaOh I know you didn't rip the logo.. That was just a 'BTW'.
Oh, and I kind of answered that question already. highlight_string().
<?php
$code = "<?php echo 'hello world'; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
This demonstrates two ways to use it. The first will colour the code, and print, while the second will colour the code and then return a string.
I wouldn't call <?php include($file); ?> or <?php phpinfo(); ?> "code snippets"... Well technically, they are, but still.. Make one 'snippet' for every function there is, why don't you are you going to even try the .phps way. that will work just fine as you have to make a file to do that and it wouldn't lead to prblems like you had before. but if it is code you want like I do on my site then what Rydberg suggested is the only way. it is all up to youThanks man! I am going to try the highlight string. I will check that out.
Scoutt what do you mean by the *.phps do I name the file that or rename the source.php with the extension *.phps?
Yes, I was going to try that way, just jumped ahead and thoguht of another idea.well for any file you want to color code you will need to make a copy and rename it to .phps
but more dynamic will be the highlight string way.ok, I get the phps extension way now. When I go and use the php highlight function, part of the code gets "processed" and part just displays text.
I made a demo page of the highlight function.
demo page for highlight (<!-- m --><a class="postlink" href="http://www.rksunderground.com/highlight.php">http://www.rksunderground.com/highlight.php</a><!-- m -->)
well you get a parse error at that page, haha
"; highlight_string($code); $colourcode = highlight_string($code, true); echo $colourcode; ?>
I am at school and I am using Dreamweaver and that is the code snippet that gets displayed on the copy locally but when I look at it remotely it is a error.is that the full line?
php color will color everything between the <? ?> tags, anything outside of that will be black like regular html text.
you can change this if you want with a ini_set() function. you can change all of the colors.This is the code I am using.
<?php
$code = "<? include "filename"; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
When I look at it in Dreamweaver its is where it ends.
";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
its almost as if it is just recongizing include and not the rest.you can't do it that way.
you have to stick the code in a variable inside that file and then highlight it. you can't stick an include in a variable like that.
$code = "<? echo\" some code here\"; ?>";
echo highlight_string($code, true);<?php
$code = "<? include \"filename\"; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
you didn't escape the quotes... And this code will print the coloured code twice, just so you know.. I was just demonstrating two different ways to use the highlight_string() function.
Hmm, scoutt, I don't think he's trying to include a file there, I would guess it's just some sample code, just to test the highlight_string() function..ok scoutt, this is what I have now for code, would this be right?
<?php
$code = "<?php echo '<?php echo $_SERVER['REMOTE_ADDR']; ?> '; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
I put the echo variable in side the actual echo that will display it on the page.
And Rydberg, what do you mean by two methods of highlighting?I'm talking about two ways to use that function, highlight_string(). Notice the parameter count in my examples.
highlight_string($string) will highlight the code in $string AND print it to the browser.
$newstring = highlight_string($string, true) will highlight the code in $string BUT send the results back as a string, and NOT print it to the browser. This can be useful, if you'd like to edit it in some way.
That code you have there is pretty messed up.. I just think scoutt misunderstood, but im not sure. Try my last example, and it'll work.ok, I get what you meant now. By your last example code do you mean this one:
<?php
$code = "<?php echo 'hello world'; ?>";
highlight_string($code);
$colourcode = highlight_string($code, true);
echo $colourcode;
?>
would the code be placed in where "hello world" is? Ex. I would use a like include or another php code there. The code above is the code I used. Is that what you meant by the last example?I don't think he was trying to include either but the code didn't think that.
<?php
$code = "<? echo\" some code here\"; ?>";
highlight_string($code);
?>
that code works just fine. that is how I do it as well.
$code = "<?php echo '<?php echo $_SERVER['REMOTE_ADDR']; ?> '; ?>";
that will print but it will look funny. you don't need the extra <? tags in there.
remember, the highlight_string will highlight anything in the variable, you don't need to do anything special apart from what I did here.thanks I got it working with a include and a show php info. Is it possible to have multiple lines of code in there? I tried it with a last modified script and a couple others and I got errors.
<table width="260">
<tr>
<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime("filename.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?>" highlight_string($code); ?></center></td>
</tr>
</table>because you forgot a semi-colon at teh end of the code variable.
<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime("filename.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?>"; highlight_string($code); ?></center></td>that, and that you again didn't escape the quotes in the string.what quotes do you mean?<td bgcolor="#FFFFFF"><center><?php // php ip address example for snippets.
$code = "<?
$last_modified = filemtime(\"filename.php\");
print(\"Last Modified \");
print(date(\"m/j/y h:i\", $last_modified));
?>"; highlight_string($code); ?></center></td>I found a highlight function that used a external txt file and you put the code in there and I cant remember where I found it. It was like highlight implode then a link to the txt file. Does anyone know what I am talking about?thats easy.
<?php
$text = file("text.txt");
$string = '';
for ($i=0; $i<count($text); $i++){
$string .= $text[$i];
}
highlight_string($string);
?>