Jump to content

Different Between Short Tags And <?php Tags In A Get Url?


eldan88

Recommended Posts

Hey I just wanted to know what is the difference between this url

 

order_number=<?=$_GET['order_number']?>

 

and this url:

 

order_number=<?php $_GET['order_number']?>

 

In addtion to that I want to also ask..

  1. which one is better to use
  2. why is there 2 equal signs in short tags?

Link to comment
Share on other sites

The second one doesn't echo anything. The first one may or may not echo something, depending on the version of PHP being used, and/or the php.ini file.

 

Here is how the full code looks like now

 

[url="http://www.yourserver.com/directory/filename.php?order_number=<?=$_GET"]http://www.yourserve...number=<?=$_GET[/url]['order_number']?>

 

There is no echo statement its get sent to an XML document, and what do you mean the first one may or may not echo something?

Edited by eldan88
Link to comment
Share on other sites

Hey Jessica,

 

Thank you so much for your help. I had read through the documentation based on the links you have provided and I see what the difference between them are.

 

 

Although since my developer used them .. are they safe to use?

 

Did you even attempt to look this up?

Further more, if you ran that code, you would see what the difference is.

 

Those are not normal short tags.

http://www.php.net/m....short-open-tag

http://us3.php.net/m...nction.echo.php

 

Hey thanks for your help

Did you even attempt to look this up?

Further more, if you ran that code, you would see what the difference is.

 

Those are not normal short tags.

http://www.php.net/m....short-open-tag

http://us3.php.net/m...nction.echo.php

Link to comment
Share on other sites

As Pikachu posted quite explicitly, they are not the same things.

 

<?= $_GET['order_number'] ?>

 

is not equivalent to

 

<?php $_GET['order_number'] ?>

 

It is actually equivalent to:

 

<?php echo $_GET['order_number']; 

 

Understanding the difference is pretty important.

 

Due to the fact that short open tags conflicts with inline xml, php short open tags . They are "safe" so long as your server doesn't have scripts that start with blocks like this:

 

<?xml version="1.0"?>

 

Needless to say, this would confuse the php parser into thinking that it needed to parse the code, when really you meant to output an xml document.

 

However, as of php version 5.4, the = syntax will always work.

Link to comment
Share on other sites

Thanks for that useful answer. I really apperciate it!

 

As Pikachu posted quite explicitly, they are not the same things.

 

<?= $_GET['order_number'] ?>

 

is not equivalent to

 

<?php $_GET['order_number'] ?>

 

It is actually equivalent to:

 

<?php echo $_GET['order_number']; 

 

Understanding the difference is pretty important.

 

Due to the fact that short open tags conflicts with inline xml, php short open tags . They are "safe" so long as your server doesn't have scripts that start with blocks like this:

 

<?xml version="1.0"?>

 

Needless to say, this would confuse the php parser into thinking that it needed to parse the code, when really you meant to output an xml document.

 

However, as of php version 5.4, the <?= syntax will always work.

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.