Changes

Jump to navigation Jump to search

Coral: php short open tags

2,835 bytes added, 13:42, 12 November 2011
Created page with "<div id="top" style="margin:0;padding: 0px 0px 0px 5px; color: #000; background-color: #FFFFEB; border: 1px solid darkslateblue;"><span id="top" style="margin:0;padding: 0px;font..."
<div id="top" style="margin:0;padding: 0px 0px 0px 5px; color: #000; background-color: #FFFFEB; border: 1px solid darkslateblue;"><span id="top" style="margin:0;padding: 0px;font-size:12px">'''''Coral'' :'''&nbsp; [[Coral: php intro|PHP]] | [[Coral: php short open_tags|PHP - Short open tags]] | [[Coral: php pear|PHP - PEAR Auto Install]] | [[Coral: php pear manual install|PHP - PEAR Manual Install]] | [[Coral: php apc|PHP - APC]]</span></div>

{|style="margin-top:5px;"
|-valign="top"
|
<span style="margin-bottom:5px;font-size:25px;color: #31799F;">PHP - Short open tags</span>

PHP short open tags allow you to write slightly less code! These were most beneficial when inserting pieces of PHP code into HTML however:

'''''Warning'''''

* Do not use the short form ('''<? ?>''') of PHP open tag.
* Use the long form of PHP open tag ('''<?php ?>''').
* '''Always''' switch "short form open tags" to "off" in the PHP configuration file.


__TOC__

|
{| cellpadding="0" cellspacing="0" style="margin-left:6px;margin-bottom:5px;padding-left:6px;padding-right:6px;font-size:11px;background-color: #FFFFEB;border: 1px solid darkslateblue;"
|-
|colspan="2" style="font-weight:bold;"| UniServer&nbsp;8-Coral
|-
|&nbsp;||[[Coral: Introduction|Home]]
|-
|&nbsp;||[[Coral: start quick start|Quick Start]]
|-
|&nbsp;||[[Coral: general intro|General]]
|-
|&nbsp;||[[Coral: apache intro|Apache]]
|-
|&nbsp;||[[Coral: mysql intro|MySQL]]
|-
|<span style="font-size: 14px;">ยป</span>||[[Coral: php intro|PHP]]
|-
|&nbsp;||[[Coral: msmtp intro|MSMTP]]
|-
|&nbsp;||[[Coral: cron intro|CRON]]
|-
|&nbsp;||[[Coral: dtdns intro|DtDNS]]
|-
|&nbsp;||[[Coral: dbbackup intro|Db Backup]]
|-
|&nbsp;||[[Coral: perl intro|Perl]]
|-
|&nbsp;||[[Coral: index main|Main Index]]
|}

|}
==Why==
Using short tags is discouraged because they are in conflict with XML's open tag - '<?xml'. If the file is actually XML, the PHP interpreter will process everything after the '<?' as PHP code, resulting in a parsing error.

Another reason to always use full PHP opening tags is to avoid the unknown. For example, a hosting provider that doesn't allow short open tags (<? ?>) on their servers.


==Testing older scripts==

For testing older scripts, you can switch short open tags "on" temporarily. After testing, be sure to switch short form open tags "off" and retest the scripts

==Convert older scripts as follows:==

Replace all occurrences of ('''<? ?>''') with ('''<?php ?>''')

Replace all occurrences of ('''<?=''') with (<'''?php echo''')

Replace all occurrences of ('''<% %>''') with ('''<?php ?>''')

There's a similar issue with ASP-like '''<% %>''' tags. The Uniform Server default is asp_tags = Off
Replace all occurrences of ('''<% %>''') with ('''<?php ?>''')


'''''[[#top | Top]]'''''

----

[[Category: Uniform Server 8-Coral]]

Navigation menu