views:

224

answers:

4

I'm very surprised I couldn't find this question here, which makes me very sure it is here and I just didn't see it. Regardless, I'll ask again.

How do I echo a forwardslash "/"?

echo <?php echo $_SERVER['HTTP_HOST'] ?> . '/directory/';

Thanks -J

A: 
echo $_SERVER['HTTP_HOST']  . '/directory/';
John Conde
+3  A: 

The way you echo a forward slash is like this:

echo "/";

I think your problem is that you're opening/closing PHP tags inside what I assume is already a block of php. Change to this:

<?php
echo $_SERVER['HTTP_HOST'] . '/directory/';
nickf
wow, I think I need to hang it up for the day if that's what I'm missing. Thanks.
Jascha
A: 

You're putting in extra <?php tags, which you don't need.

<?php

// Insert other PHP code here

echo $_SERVER['HTTP_HOST'].'/directory/';

// Insert more PHP code here

?> <!-- You can put HTML here -->
waiwai933
A: 

Ya, you've closed your PHP tag while still using PHP. Try this:

<?php echo $_SERVER['HTTP_HOST'] . '/directory/'; ?>

With regard to echoing a forward slash, no escape is necessary:

<?php echo "/"; ?>
swt83