Jump to content

[SOLVED] PHP Freak Code


frost

Recommended Posts

Ok so the thing is I want to html code around the tutorial:

 

<table>

<tr><td>

<b>TITLE</b></td></tr>

<tr><td>

TUTORIAL STUFF

</td></tr></table>

 

and all of that is stored in my database, so if I do htmlspecialchars(); it will also display the table code...

 

 

Link to comment
Share on other sites

htmlspecialchars() will allow you to display html tags and characters on the page. Barrands even better method highlight will provide the lovely blue,red,green and orange colors for the various php and html elements in the text. If your mysql data is returned exactly as you typed it it will produce...

 

TITLE

TUTORIAL STUFF

 

 

 

Link to comment
Share on other sites

Well I tried:

 

$string ="<table>
<tr><td>
TITLE</td></tr>
<tr><td>
TUTORIAL STUFF
</td></tr></table>";

echo htmlspecialchars($string);

 

Output:

 

<table> <tr><td> TITLE</td></tr> <tr><td> TUTORIAL STUFF </td></tr></table>

 

Am I missing something?

Link to comment
Share on other sites

Ok so the thing is I want to html code around the tutorial:

 

<table>

<tr><td>

<b>TITLE</b></td></tr>

<tr><td>

TUTORIAL STUFF

</td></tr></table>

 

and all of that is stored in my database, so if I do htmlspecialchars(); it will also display the table code...

 

 

 

Why are you storing all that in the database? Just store your tutorial part.

Link to comment
Share on other sites

The tutorial includse stuff that is code and stuff that is just me explaining things.

 

How about this route:

 

$Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text);

 

This is a BBcode thing but I wonder if I could be adapted?

 

In this example it replaces everything between the bbcode "code" values. Is it possible to do something like this and instead of replacing everything just replace all instances of < and > with < > ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.