Hey there,
I wanted to display PHP code like used on these forums (the old version though) and i found a function called highlight_string() which i thought worked perfect to what i wanted. When i tried it i found out that no matter what i do, if u put a var in it, eg highlight_string("$_REQUEST['var']");, all that it shows is either the contents of the var if it is set elsewhere on the page (eg On my site i use index.php?p=tutorials, then i wanted to make a tutorial of how i did them, but if i put if (isset($_REQUEST['p'])) it replaces it with 'tutorials'). Also if the var has no value (i tried just using $page instead) it just displays nothing.
Is there anyway to fix this ? or should i find a different way of doing it ?
Thx
// Getran
highlight_string()
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
sorry for late reply but i wasn't available to access comp. Here is what i'm using, and trying to display.
atm, all that it puts out is:
Code: Select all
<?
highlight_string("<?
if (isset($_REQUEST['p']))
{
$inc = $_REQUEST['p'].".inc";
if (!file_exists($inc))
{
echo "File not found";
}
else
{
include($inc);
}
}
else
{
include("index.inc");
}
?>");
?>Code: Select all
<?
if (isset())
{
= .".inc";
if (!file_exists())
{
echo "File not found";
}
else
{
include();
}
}
else
{
include("index.inc");
}
?>Just tweak the quotes (as mentioned above).
Code: Select all
<?php
highlight_string('<?
if (isset($_REQUEST[''p'']))
{
$inc = $_REQUEST[''p''].".inc";
if (!file_exists($inc))
{
echo "File not found";
}
else
{
include($inc);
}
}
else
{
include("index.inc");
}
?>');
?>