Moonbat
03-27-2008, 05:54 PM
Alright, well, I'm working on a project, here is the gist of what it is. I got the idea from another site.
When someone is reading PHP code, they might wonder what a certain function, like 'explode' or 'nl2br' does. They would probably Google it up. But this makes the process easier. What you do is enter your PHP code into the text box, and then when you submit it, it'll output the PHP code, but with many important statements and functions already hyperlinked to the PHP.net function reference. It may not be particularly useful, but it's my first short-term project.
Sadly, I've come accross my first hurdle. Here is the full code:
<html>
<head>
<title>PHP Keyword Parser v0.*</title>
<style type="text/css">
textarea
{
background: black;
color: #FFFFFF;
}
a:link
{
color: #FFFFFF;
font-weight: bold;
}
a:visited
{
color: #FFFFFF;
font-weight: bold;
}
pre
{
color: white;
}
</style>
</head>
<body bgcolor="666666">
<?php
if (isset($_POST['thephpcode'])){
$thephpcode = $_POST['thephpcode'];
$thekeywords = array("echo", "print", "fsockopen");
$thelinkarrays = array("<a href='http://www.php.net/echo'>echo</a>", "<a href='http://www.php.net/print'>print</a>",
"<a href='http://www.php.net/fsockopen'>fsockopen</a>");
str_replace($thekeywords, $thelinkarrays, $thephpcode);
print "<pre>$thephpcode</pre>";
} ;
?>
<center><font color="0066FF" face="Verdana"><h*>PHP Keyword Parser v0.*</h*></font></center>
<center><font face ="Verdana">Enter your PHP code into the text box below, and then press 'Parse'</font></center>
<br>
<form name="thephpcodeform" action="<?php echo $PHP_SELF; ?>" method="POST">
<center><textarea name="thephpcode" rows="22" cols="*00%"></textarea><center>
<input type="submit" value="Parse">
</form>
</body>
</html>
I get no errors (and I haven't done anything to suppress errors, such as @, so I should get errors if there are any because I've gotten them before).
But the problem is when I enter in the code, it just echoes back the code instead of replacing the specified keywords with the linked versions. I've checked the code >*000 times and I can't figure out why it isn't working. I'm testing this on AwardSpace webhost, but I don't think that makes any difference.
If you can help, I'd appreciate it.:D
When someone is reading PHP code, they might wonder what a certain function, like 'explode' or 'nl2br' does. They would probably Google it up. But this makes the process easier. What you do is enter your PHP code into the text box, and then when you submit it, it'll output the PHP code, but with many important statements and functions already hyperlinked to the PHP.net function reference. It may not be particularly useful, but it's my first short-term project.
Sadly, I've come accross my first hurdle. Here is the full code:
<html>
<head>
<title>PHP Keyword Parser v0.*</title>
<style type="text/css">
textarea
{
background: black;
color: #FFFFFF;
}
a:link
{
color: #FFFFFF;
font-weight: bold;
}
a:visited
{
color: #FFFFFF;
font-weight: bold;
}
pre
{
color: white;
}
</style>
</head>
<body bgcolor="666666">
<?php
if (isset($_POST['thephpcode'])){
$thephpcode = $_POST['thephpcode'];
$thekeywords = array("echo", "print", "fsockopen");
$thelinkarrays = array("<a href='http://www.php.net/echo'>echo</a>", "<a href='http://www.php.net/print'>print</a>",
"<a href='http://www.php.net/fsockopen'>fsockopen</a>");
str_replace($thekeywords, $thelinkarrays, $thephpcode);
print "<pre>$thephpcode</pre>";
} ;
?>
<center><font color="0066FF" face="Verdana"><h*>PHP Keyword Parser v0.*</h*></font></center>
<center><font face ="Verdana">Enter your PHP code into the text box below, and then press 'Parse'</font></center>
<br>
<form name="thephpcodeform" action="<?php echo $PHP_SELF; ?>" method="POST">
<center><textarea name="thephpcode" rows="22" cols="*00%"></textarea><center>
<input type="submit" value="Parse">
</form>
</body>
</html>
I get no errors (and I haven't done anything to suppress errors, such as @, so I should get errors if there are any because I've gotten them before).
But the problem is when I enter in the code, it just echoes back the code instead of replacing the specified keywords with the linked versions. I've checked the code >*000 times and I can't figure out why it isn't working. I'm testing this on AwardSpace webhost, but I don't think that makes any difference.
If you can help, I'd appreciate it.:D