Web Hosting Talk







View Full Version : Simple PHP Question


LayeredZoneHosting
05-23-2006, 03:37 PM
How do I get a slash to show up in php?

For example:

I had=

echo "$site $number";

I want it to have a slash in between, so I put echo "$number / $site"; So it would show up as EX. 5/mlb.com

But it gives me an error.

It tells me there's an unexpected /.

What Can I Do?

StackHost
05-23-2006, 03:41 PM
<? php echo $site; echo " / "; echo $number; ?>

LayeredZoneHosting
05-23-2006, 03:44 PM
That doesnt work.

here is the line i need to fix.


echo "<br>To send this image to friends and family, copy and paste this code: <br><font size=2 color=gray><textarea rows=3 cols=60>" . $site . Pics . $number2 . "</textarea></font>";


I need it to say /Pics

uncleThirteen
05-23-2006, 03:56 PM
That doesnt work.

here is the line i need to fix.


echo "<br>To send this image to friends and family, copy and paste this code: <br><font size=2 color=gray><textarea rows=3 cols=60>" . $site . Pics . $number2 . "</textarea></font>";


I need it to say /Pics


Try:


echo "<br>To send this image to friends and family, copy and paste this code: <br><font size=2 color=gray><textarea rows=3 cols=60>" . $site . "/Pics" . $number2 . "</textarea></font>";

webviz
05-23-2006, 04:25 PM
<?php echo "{$site}"."/"."{$number}\n"; ?> and if you would like to add a line break <?php echo "{$site}"."/"."{$number}<br />\n"; ?>

uncleThirteen
05-23-2006, 04:40 PM
<?php echo "{$site}"."/"."{$number}\n"; ?> and if you would like to add a line break <?php echo "{$site}"."/"."{$number}<br />\n"; ?>


Actually, that will echo the braces, which i don't think he wants....:peace:

webviz
05-23-2006, 04:50 PM
Actually, that will echo the braces, which i don't think he wants....:peace:
No, it does not. I suggest you consult the PHP Manual.

uncleThirteen
05-23-2006, 05:08 PM
My apologies - I tend to avoid using language constructs that may confuse the programmers that may inherit my code, so I usually do not put anything in quotes that will not actually print, and often forget that such things do exist as a "feature".

webviz
05-23-2006, 05:25 PM
My apologies - I tend to avoid using language constructs that may confuse the programmers that may inherit my code, so I usually do not put anything in quotes that will not actually print, and often forget that such things do exist as a "feature". Yes, I can understand how
<?php echo $site . '/' . $number . '<br />\n'; ?> would work, too.