Hyp3r grunt
12-09-2007, 09:19 PM
This is my converter. It converts html to html that's friendly with an RSS 2.0 feed.
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:stafflogin.html");
}
?>
<?php include('./above.inc'); ?>
<title>Website - The Converter</title>
<?php include('./below.inc'); ?>
<div id="main">
<h1>The Converter</h1>
<?php
$phrase = "<p>This is a test.</p>";
// For the 'phrase' variable remember to find all the double-quotes and put backwards slashes before them. '"' would have to be changed to '\"'.
$healthy = array("<", ">", "\"", "\'", "&");
$yummy = array("<", ">", """, "'", "&");
$newphrase = str_replace($healthy, $yummy, $phrase);
echo "<h3>Before:</h3>";
echo "$phrase";
echo "<h3>After:</h3>";
echo "<p>$newphrase</p>";
?>
</div>
<?php include('./furtherbelowalternate.inc'); ?>
The problem is that when I put text in the phrase variable I have to go and find all the double quotation marks and put backslashes before them to make the converter work. Is there a way I can make the converter do what I want it to do without having to go through everything I set as the phrase variable and putting backslashes before all the double quotations?
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:stafflogin.html");
}
?>
<?php include('./above.inc'); ?>
<title>Website - The Converter</title>
<?php include('./below.inc'); ?>
<div id="main">
<h1>The Converter</h1>
<?php
$phrase = "<p>This is a test.</p>";
// For the 'phrase' variable remember to find all the double-quotes and put backwards slashes before them. '"' would have to be changed to '\"'.
$healthy = array("<", ">", "\"", "\'", "&");
$yummy = array("<", ">", """, "'", "&");
$newphrase = str_replace($healthy, $yummy, $phrase);
echo "<h3>Before:</h3>";
echo "$phrase";
echo "<h3>After:</h3>";
echo "<p>$newphrase</p>";
?>
</div>
<?php include('./furtherbelowalternate.inc'); ?>
The problem is that when I put text in the phrase variable I have to go and find all the double quotation marks and put backslashes before them to make the converter work. Is there a way I can make the converter do what I want it to do without having to go through everything I set as the phrase variable and putting backslashes before all the double quotations?