i have one complete website
which was written in php4, now my hosting server is PHP Version 5.3.2, windows 2008 server
and my site is not working, what i found is old site use following syntax
<?
but if i change it into
<?php
page start working. is there any way to solve this issue...
PHP Version 5.3.2 work with
<?
any script which change all
<? to <?php
in all pages.
This is not down to the PHP version, but depends on the short_open_tag php.ini setting.
You can change the ini setting to "1", but the use of short open tags is generally discouraged these days.
Short tags are a discouraged feature of PHP. You should convert all <? to <?php, because as of PHP 6.0, they will be deprecated. (This is partially to better support XML documents, which have a tag that starts with <?)
BTW, you can turn them on in your configuration.
the following code snippet helped me convert all short tags to proper PHP tags, hope it helps you too:
REPLACING SHORT TAGS WITH PROPER PHP TAGS (archived copy)
There is a directive in your php.ini file called "short_open_tag". This is what allows you to use the shorthand or not. They should not be used anymore though, so its better if you update all tags to the new format.
Metropolis
Related
This question already has answers here:
Are PHP short tags acceptable to use?
(28 answers)
Closed 9 years ago.
I know this is probably a noob question but I really can't figure this out.
I was ask to modify the existing php code so I downloaded the code and try running on my machine but i can't get it to work.
from my understand we write php code in
<?php
//some code
?>
but this code that i downloaded uses php code like this
<?
//some code
?>
It doesn't work on my machine but it works on the production server.
Does anyone know how this works?
Update:
Looking at the code in details, this is example of the code
<?php include $_SERVER["DOCUMENT_ROOT"]."/pages/layouts/summary.php"; ?>
then in summary.php
<?
session_start();
require_once $_SERVER["DOCUMENT_ROOT"]."/includes/mysql.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/includes/functions.php";
//more code ...
?>
When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.
PHP also allows for short tags <? and ?> (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.
Read here http://php.net/manual/en/language.basic-syntax.phptags.php
; http://php.net/short-open-tag
short_open_tag = Off
Open short tag from php.ini file
short_open_tag = on
if short_open_tag is set to on in the php.ini file then we can use instead of
but its madatory to use if short_open_tags are set to off in the php.ini file.This is off on default
I recently set up an AWS EC2 instance and installed Apache, PHP, and MySQL on the 64-bit Linux server using yum
Then I uploaded my php files for my contact form in /var/HTML/WWW
It displays fine except parts of my contact form are being displayed. They are PHP— the PHP tags and the code within them are being shown.
Here is a live example: 23.23.152.36
And here is a version on another server where its working fine.
Does anyone have any ideas why this is happening?
Do you have PHP enabled on your webserver? For Apache, you may need to modify httpd.conf to enable PHP.
Can you run phpmyinfo() on your webserver?
Enable short_open_tag in you php.ini
short_open_tag
Default Value: On
Development Value: Off
Production Value: Off
shorthand notation is on its way to deprication, i wouldnt suggest building code with shorthand notation anymore.
just use <?php echo ?>
You want to change <?php=$name;?> to <?= $name ?>. That's what you need to do if you want to use the shorthand notation.
This question already has answers here:
How to enable PHP short tags?
(21 answers)
Closed 1 year ago.
I have an application that has some PHP code, the PHP open/close tag I'm using is:
<?
$anything;
echo problem;
?>
The application is not running.
Are there some rules for this type of open/close ( maybe a php.ini config.) that might cause the application not to run ?
P.S. Would the better way be to change all <? to <?php ?
run a phpinfo(), look for the path which php.ini is used. Then open the file and find short_open_tag
Set it to on or off.
But in general.. use <?php ?> this is better.
Use <?php ?>. <? ?> are referred to as short-tags, and not every server is setup to support them.
The <? version of the open tag is called a "short tag." While the php community prefers the use of the full <?php version of this tag, it is still acceptable to use short tags. Ideally, we would all use <?php all the time, but we often deal with legacy code, and changing all occurrences of <? to <?php can be tedious and time consuming. If you find yourself in a situation where you need to allow the php interpreter to recognize the short tag, you may enable it in the php.ini file using the "short_open_tag=1" directive.
For new code you are developing, I would recommend using the long version of the tag <?php, as you know that will be compatible regardless of the ini setting used in the servers php.ini config. For more information on this, see: Are Php Short Tags Acceptable To Use here on StackOverflow.
To figure out why your application is not running, check the webserver error logs, as well as the php error logs, and consider turning up php's error reporting level. This can also be done in the php.ini file using the error_reporting directive. This will allow you to determine what is causing the application to not run, and then you will be more informed for further questions.
You should use <?php ?> to ensure correct parsing.
There are specific times where it is suited or possible to use the short tags like this for PHP
<?=$sign['last_connected']?>
notice the <?= instead of <?php echo
I have PHP, IIS7, ReWrite Module for IIS and Zend all installed.
I can execute PHP pages just fine, even got PHPINFO showing up.
I setup a Zend quickstart app on IIS and when I open it this is what I see:
You can see from the source that it's not executing the <= portions.
Any idea what needs to change?
alt text http://www.gonrad.com/200902/zendiis.jpg
You need to enable shortags in your php.ini:
short_opentag = on
However, even though Zend's examples use the open tag, for portability you really should use the full echo statement as not all webhosts allow for short_opentag. The short tag might save a bit of time typing but may actually be worse in the long run.
make sure <? is enabled and not just <?php
if you use <?
php.ini --->short_opentag=On
I was using xampp to develop locally and then I installed the PHP from the direct installer. Now in some of my PHP code, only PHP code that starts with "<?php" is correctly parsed. Anything that starts with "<?" or "<?=" is completely ignored and just left as is.
How can I adjust the configuration to parse either tokens?
This is a php.ini setting named
short_open_tag = 1 # (enabled)
I recommend you to disable short_open_tag and only work with <?php. When short_open_tag is enabled, it can collide with the XML processing instruction <?xml as both the PHP open tag and XML PI start with a <?.
By using only <? as start preprocessor startup, you can get the preprocessor confused with well formed XML documents. XML stands <? for processing-instruction, imagine an XHTML document with embeded XML that requires XSLT processing... The preprocessor will get confused with the stylesheet processing instruction and will throw an error.
It's higly recomended to use the <?php processor starting tag, try using the
short_open_tag = Off in your php.ini. Also, you can try using <?php ini_set('short_open_tag', 'On'); > if you are getting problems.
You can set short_open_tag = On in the php.ini
It's a configuration option, more information on: http://www.php.net/ini.core (look for short_open_tag).
For the newer version:
short_open_tag = On