hallo there

i had built a bunch of webpages and they ve been working fine for months.
yestarday i installed this website to another computer after i instaled easyphp 5.4.6 (Apache 2.4.2, mysql 5.5.27 and php 5.4.6).
it seems that nothing is working as it should. after i debug my code i found out that the tag <?, that i used a lot, can not be parsed. it is not understantable by php. The php recornizes only <?php tag.

Is there a solution to deel with it all at once or i have to find every <? tag in my code and replace it? Its a lot of code....

Excuse my English...

Recommended Answers

All 10 Replies

There are tools like PowerGrep that can help you with a search and replace in a lot of files at once. It has a 30-day trial. I'm a satisfied customer, really made my life easier.

i though that it is a just a setting in my php.ini that i have never learned of. Is there another way? we are talking about 30000 lines of code. Can we adjust php to consider <? as <?php

Yes, you could enable short_open_tags, but I don't recommend it. If you ever need to upload to a shared host, then your code won't work (again).

commented: this one is correct, you should enable short_open_tags in php.ini file before using php short tags. +2

as pritaeas said, you should set short_open_tags to true:

ini_set('short_open_tags', 1);

ok thanks
just a question about that. Why this happened? the php5 caused it?

and some more.. sorry..

i can not search and replace automatically because i use the tags <? and <?php both. if i ask to replace <? it will also replace <?php to <?phpphp. is this Rihgt?

About the second solution. I have to insert this line to every php file i use (up to 300). is this right?

but I don't recommend it

I don't think pritaeas said to do it, but rather you "could" do it, but he doesn't recommend it.

You can search for just "<?" and replace it with "<?php". If you do it right with regex it should not touch the existing "<?php". This will probably work for that ^(<\?)

in your previous configuration, short tags were enabled.

you can replace <?php to <? and then replace <? to <?php

or replace '<? ' (with space after questionmark) to '<?php '
the first way seems better to me

commented: logical workaround +6

thanks a lot. i tried to do so but i can not find the right regular expression to put into "find" and "replace".
Is someone has the experience and knowlege to tell me so?

I gave a regex that should work ^(<\?)

You could also do what dorco suggested and turn all of the "<?php" into "<?" and then afterwards turn all of the "<?" into "<?php".

it worked.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.