Is there a php.ini setting to turn <?=$phpval?>
-style output on, or has someone on this project been smoking too much ASP?
Asked
Active
Viewed 155 times
2

Lightness Races in Orbit
- 378,754
- 76
- 643
- 1,055

wedstrom
- 555
- 1
- 3
- 14
-
5"smoking to much ASP?" Golden quote. – Christopher Marshall Jan 29 '12 at 02:18
-
1As a side note, you can quickly check php syntax using online editors such as ideone. – JRL Jan 29 '12 at 02:23
-
1You can also quickly load up the PHP manual in your web browser. – Lightness Races in Orbit Feb 28 '12 at 23:08
3 Answers
2
There is, but it is deprecated.
You are looking for short_open_tag
which enables <?
(DANGER because of xml opening tags that are the same) and <?=
(no danger)
As of php 5.4, <?=
will be enabled even if short_open_tag
is set to Off.
See the documentation.

greg0ire
- 22,714
- 16
- 72
- 101
-
3Note that `=` is always allowed in PHP 5.4, whether `short_open_tag` is on or not. – Jan 29 '12 at 02:22
-
@duskwuff: that's what I tried to say, but not putting the `=` between ` messed up my answer. – greg0ire Jan 29 '12 at 02:26
-
Note also that in php 3.3.8 (And probably earlier versions as well) it turns on/off with the short_open_tag php.ini directive.Also, if you change that setting in your ini file, restart apache and still nothing happens, make sure your using the correct ini file as shown in phpinfo(); Derp. – wedstrom Jan 29 '12 at 02:42
-
-
-
@greg0ire: The thing that your answer and the first comment talks about. – Lightness Races in Orbit Feb 29 '12 at 10:34
-
They are doing that so that people can use `=` safely, that is, whithout having `` recognized as a php opening tag. – greg0ire Feb 29 '12 at 10:41
2
Yes,
<?php $var = 'Hello, World!"; ?>
<?= $var ?>
Is the same as;
<?php $var = 'Hello, World!"; ?>
<?php echo $var; ?>

Francisco Presencia
- 8,732
- 6
- 46
- 90

Skittles
- 2,866
- 9
- 31
- 37
1
Yes, Its a valid statement, and as @greg0ire mentioned you can turn it on by editing the short_open_tag
in php.ini however using <?php
has been known as a better practice specially if you are writing your application for sale to the public, because <?php
would work with most shared hosting configurations however <?
is sometimes not allowed/not activated, so its easier for users to use your script if you use <?php
.

Ahoura Ghotbi
- 2,866
- 12
- 36
- 65