Welcome Guest, Not a member yet? Register   Sign In
I can not get <?= to work on one of my servers, any ideas why ?
#1

[eluser]tobias eriksson[/eluser]
Typically we use <?php echo $variabel; ?>when we want to use php to do something,
but as you also know it is possible to use <?=$variable?>
and that worked fine on the server I use for my company (webhosting web10.se)
but when I tried to integrate my system into the customers webserver it wouldn't translate that at all.
Anyone who knows why ?
What is missing to get that to work

/Tobias
#2

[eluser]Philo01[/eluser]
In order to make short tags you work you have to enable it in your configuration file php.ini

Code:
short_open_tag "0"

Should be turned into:

Code:
short_open_tag "1"

My advice is to not use php short tags in your php applications that you are going to install on different servers.
Since not all servers support it or the hosting company doesn't allow it.

Quote from the web:
Quote:Note: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.
#3

[eluser]tobias eriksson[/eluser]
Ohh, I see,
Thanx
/Tobias
#4

[eluser]BrianDHall[/eluser]
Oh yeah, but CI has a feature that fixes this for you! I like short-tags myself so I just keep it on regardless of what options my servers might have. search in your config.php file for this option:

Code:
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files.  Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = TRUE;

Yet another reason CI rules!
#5

[eluser]kurucu[/eluser]
How reliable is this feature? I saw it the other day and thought it looked handy. Does anyone use it? What sort of performance impact does it have?

Despite liking short tags (a hangover from early ASP work) I have just stuck to long tags now... JIC.
#6

[eluser]BrianDHall[/eluser]
I use it on everything and haven't run into a problem yet. I'd never used short tags until I started using CI, now I freely mix <?php with <?= without issue.
#7

[eluser]nizsmo[/eluser]
[quote author="kurucu" date="1253674080"]How reliable is this feature? I saw it the other day and thought it looked handy. Does anyone use it? What sort of performance impact does it have?

Despite liking short tags (a hangover from early ASP work) I have just stuck to long tags now... JIC.[/quote]

I've had some experience with the dynamic short tag rewrite feature for CI, whilst its useful, if you dig into the code deeper, the rewrite is actually replacing using regular expression and then using the eval() function to execute the code.

I haven't done any kind of benchmarks, but my guess is that it is probably quite a lot slower due to the regular expression matching and the extra PHP interpretor called using eval().

Just my opinion though, and I agree it is an extremely handy feature to have!
#8

[eluser]kurucu[/eluser]
Great stuff, thanks for the replies.

Large scale eval usage and regular expressions on every view. Turns me off a bit. I think I'll write long tags for all new stuff, and only consider the option for legacy code.
#9

[eluser]BrianDHall[/eluser]
As an option you could always use short-tags, then if things starting bogging down just do a replace in files search in your IDE to replace "<?=" with "<?php echo " - best of both worlds.
#10

[eluser]bd3521[/eluser]
[quote author="BrianDHall" date="1253667530"]Oh yeah, but CI has a feature that fixes this for you! I like short-tags myself so I just keep it on regardless of what options my servers might have. search in your config.php file for this option:

Code:
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files.  Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = TRUE;

Yet another reason CI rules![/quote]
I have this enabled but after upgrading to PHP 5.3.0 and CI 1.7.2 it not longer works.
Very strange




Theme © iAndrew 2016 - Forum software by © MyBB