Meta Tags

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JF3000
Forum Newbie
Posts: 19
Joined: Tue Mar 01, 2005 2:54 am

Meta Tags

Post by JF3000 »

I dont quite understand php nor how it works, so I wanted to ask can html be placed inside those tags of php, or does the html have to reside on the outside of the tags of php?

I ask this as I wanted to know where to place meta-tags for the index.php?

Thank you.

JF3000
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

depending on how you do it, either works. 'echo' will send to the client whatever you give it, whether it appears like you wish is up to how you use it. They can be placed outside <?php ?> similarly.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

A note about meta tags, sometimes they're changing the "Headers" of a page. You can do much smoother redirects, for instance, if you have PHP send the redirect header straight from the code, not the Meta tag.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

although one should send a meta-tag enabled redirect page incase the browser (or proxy) disallows or does not support the header redirection. ;)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

feyd wrote:although one should send a meta-tag enabled redirect page incase the browser (or proxy) disallows or does not support the header redirection. ;)
and even include a link if the browser doesn't like meta redirects..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

quite true.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Yuck for "user options" :roll:
JF3000
Forum Newbie
Posts: 19
Joined: Tue Mar 01, 2005 2:54 am

Post by JF3000 »

I thank you for your posts, but being new to php I am lost.

I created some meta tags and just placed them above my php tags at the top of the php page, will this do fine or is there a better method because I am using php?

Thank you.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That'll do.

Just because you are using PHP, doesn't mean you should echo / print stuff for the sake of it.

If you can do it outside of the <?php ?> tags then that's the best (and I beleive fastest) way to do.

Examples:

Code: Select all

//Doing it outside <?php ?>
<?php

$name = 'Chris';
$age = '21';

?>
<!-- This is HTML -->
<span>My name is <?php echo $name; ?>  and I am <?php echo $age; ?> years old.</span>


//Doing it all inside <?php ?>#
<?php

$name = 'Chris';
$age = '21';

echo '<span>My name is ';
echo $name;
echo ' and I am ';
echo $age;
echo ' years old.</span>';

?>
You can echo anything, be it, words, <tags>, JavaScript or anything that shows in the web page source code. Just depends if you needs to use the PHP to do it or not. I do it outside of <?php ?> wherever possible (if it's not dynamic content).
User avatar
batfastad
Forum Contributor
Posts: 433
Joined: Tue Mar 30, 2004 4:24 am
Location: London, UK

Post by batfastad »

Sorry this is a bit far down but...
Using PHP redirects I've had trouble getting them to work with AOL, despite them working with most other browsers.
As said above, always have a meta redirect there just in case.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

be aware that relative header redirects are a somewhat recent addition to support on browsers. Some may still only support full URI's. This may explain the batfastard's problem with AOL.. although I don't know what their browser supports directly
Post Reply