Quick question

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
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Quick question

Post by Flamie »

Hey guys, I'm just wondering what is the setting in PHP.ini that I need to change in order to enable/disable this:

<?=$page?> (this is the same as <? echo $page;?>)

Thanks!
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Quick question

Post by Zoxive »

Flamie wrote:Hey guys, I'm just wondering what is the setting in PHP.ini that I need to change in order to enable/disable this:

<?=$page?> (this is the same as <? echo $page;?>)

Thanks!

Code: Select all

short_open_tag = On
But, this is not recommended, i can't remember where, but i'm pretty sure this is removed in future versions of php.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Never enable it. Ever.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

Yeah I know its not a good thing to use, I just needed to know for reference.

Thanks a lot dudes.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Descriptive subjects

Post by Luke »

Code: Select all

Never enable it. Ever.
Sometimes you need to enable it. Some people write applications with the short open tag on unfortunately. :roll: For instance... magento... :( .

And to flamie:
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: Descriptive subjects

Post by feyd »

The Ninja Space Goat wrote:Sometimes you need to enable it. Some people write applications with the short open tag on unfortunately. :roll: For instance... magento... :( .
Not true. You have three options:
  1. modify the code yourself to not use it -- fairly easy.
  2. push the developer(s) to fix their code -- can be challenging.
  3. use a different codebase that is written correctly -- variable difficulty depending on the niche level of the library in question.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

In the real world with project deadlines none of these options are practical or realistic.
1. modify the code yourself to not use it -- fairly easy.
Magento's codebase is huge and it's riddled with <?=$this?> and <? everywhere. There is no easy way to remove them. Even if there was, you have to do it again every time you update.
2. push the developer(s) to fix their code -- can be challenging.
Like you said this can be challenging. Eventually I have a feeling magento will change this, but I wouldn't count on that any time soon.
3. use a different codebase that is written correctly -- variable difficulty depending on the niche level of the library in question.
Find another decent PHP ecommerce app with the features magento has. It is totally worth turning on short_open_tags to get the functionality magento provides.

there are most definitely exceptions.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The Ninja Space Goat wrote:Magento's codebase is huge and it's riddled with <?=$this?> and <? everywhere. There is no easy way to remove them. Even if there was, you have to do it again every time you update.
There's a simple, easy way. You can easily write an adapter script that fixes it when installing the new codebase.
The Ninja Space Goat wrote:there are most definitely exceptions.
I have yet to find any.
User avatar
stakes
Forum Commoner
Posts: 48
Joined: Tue Jun 12, 2007 12:05 pm

Post by stakes »

Could someone please elaborate why short tags should not be used? Is it just deprecated or does it actually affect the code?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

There's a simple, easy way. You can easily write an adapter script that fixes it when installing the new codebase.
hmm... enable one configuration directive or write an adapter script for an entire codebase... I choose the configuration directive. My client is happy with this choice... saves him a few hundred bucks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Keeping short tags won't be supported in PHP 6, so if you ever plan to run on it.. you'll have to convert. Secondly, if you have XML in your files, it will generate parse errors unless you make accommodations. Lastly, it's a vestige from an older time that promotes poor, incompatible code -- because it's an option that can be turned off if a server admin chooses.
User avatar
The Phoenix
Forum Contributor
Posts: 294
Joined: Fri Oct 06, 2006 8:12 pm

Post by The Phoenix »

The Ninja Space Goat wrote:In the real world with project deadlines none of these options are practical or realistic.
1. modify the code yourself to not use it -- fairly easy.
Magento's codebase is huge and it's riddled with <?=$this?> and <? everywhere. There is no easy way to remove them. Even if there was, you have to do it again every time you update.[/quote]
1. There is a perl one-liner for that. Its search replace from <?=$this to <?php echo $this.
2. Run the script before the update
3. Best - submit the fixes (and it is a fix) upstream to the project. They would likely be extremely appreciative.
The Ninja Space Goat wrote:
2. push the developer(s) to fix their code -- can be challenging.
Like you said this can be challenging. Eventually I have a feeling magento will change this, but I wouldn't count on that any time soon.
Offering a "click and its done" patch to the upstream goes a long way towards getting their help.
The Ninja Space Goat wrote:
3. use a different codebase that is written correctly -- variable difficulty depending on the niche level of the library in question.
Find another decent PHP ecommerce app with the features magento has. It is totally worth turning on short_open_tags to get the functionality magento provides.

there are most definitely exceptions.
Is it possible to turn on short_open_tags per virt host? I suspect it is in .htaccess, which would limit the requirement a bit.
Saharian
Forum Newbie
Posts: 1
Joined: Thu Sep 27, 2007 3:00 pm

Post by Saharian »

Hm... could you point me somewhere that says that short tags are deprecated and which version of php it's going to happen?

Because here it says that php6 is going to have them:
http://www.php.net/~derick/meeting-note ... dd-php-var
Post Reply