PHP > HTML Replacement

Status
Not open for further replies.

Chris2k

Banned
Banned
901
2009
17
0
can any1 plz tell me how 2 do the html replacement? i googled it and came cross the: strip_tags( blah ) function but i dunt thinkz it'll work.

for this;

PHP:
echo "        <p class='select_text' align='center'><b>URL:</b> <input tabindex='1' value='[IMG]$siteURL/$uploadDir/$name[IMG]' onclick='this.focus();this.select();' size='65' /></p>";
 
10 comments
No need to use strip_tags as that will remove the html code too

Solution
As you included other variables which outputting, you need to use:

"{" and "}" before and after the variable respectively

So your new PHP Code:

PHP:
echo "        <p class='select_text' align='center'><b>URL:</b> <input tabindex='1' value='[IMG]{$siteURL}/{$uploadDir}/{$name}[/IMG]' onclick='this.focus();this.select();' size='65' /></p>";

My whole code:

PHP:
<?php
$siteURL = "http://localhost.com";
$uploadDir = "uploads";
$name = "filename.png";
echo "        <p class='select_text' align='center'><b>URL:</b> <input tabindex='1' value='[IMG]{$siteURL}/{$uploadDir}/{$name}[/IMG]' onclick='this.focus();this.select();' size='65' /></p>";  
?>
 
^^^^^^

He wants to actually just output the code in this form:

[SLIDE]http://lulzimg.com/i24/4bc87e7d.png[/SLIDE]

he wont be able to direct output the variables

There he would have to use { and } before outputting it

Edit: Thats only what i see the problem in the code else you need to describe more
 
Or he could simply wrap the code with variables in double quotes instead of single quotes.

OR, he could close single quotes where he encounters variables and re-open them later.

{ and } is not the only solution (assuming that's what he wants to do)
 
Hey,

first off thx Soft2050, for telling it to people nd thx l0ca for trying. life ty for nudge in de rite directionn.

i managed to do it another way tho.
 
Status
Not open for further replies.
Back
Top