Solved

PHP Syntax

Posted on 2011-03-15
3
304 Views
Last Modified: 2012-05-11
Hello,

We have a pretty extensive php app built up, with all php code in the format:

<?  ?>
instead of <?php ?>

We installed a new Apache server, and we only seem to be able to get php code to work if the brackets are in the <?php ?> format.  I can see how this is better practice, but do we have any options, other than going through all the source code, changing the format?

The server is a Mac OS X 10.6.4 server, fully updated.

Thanks
0
Comment
Question by:compsol1993
3 Comments
 
LVL 2

Assisted Solution

by:k_romych
k_romych earned 100 total points
ID: 35141093
in file php.ini set short_open_tag = On
0
 
LVL 2

Accepted Solution

by:
wrightsonm earned 300 total points
ID: 35141112
Add this as the first couple of lines to your site:

		if(ini_get('short_open_tag')==0){
			ini_set('short_open_tag',1);
			if(ini_get('short_open_tag')==0){
				die('PHP short tags are currently disabled.  This site won\'t work without short tags enabled');
		
			}
		}

Open in new window


if ini_set doesn't work you will need to find your php.ini file and change the parameter:

short_open_tag = On

Dont forget to restart apache!
0
 
LVL 3

Assisted Solution

by:pius_babbun
pius_babbun earned 100 total points
ID: 35148788
k_romych's answer is exacty correct

and if you need more explanation please check this link below

http://php.net/manual/en/ini.core.php


Hope this is helpful.

Change this in you ini file or use ini_set function to set it at the run tine

Hope this is helpful to you !
short-tag1.JPG
short-tag2.JPG
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question