Page 1 of 1

Convert <? to <?php

Posted: Thu Feb 18, 2010 4:41 am
by just_php
Hi,
I have a kind of large website which I used php all over the place. and some of the code is not mine, and I do not have any idea how they work.
They are ALL work the way the need. However, some used "<?php" and some use "<?" I am not sure where they are.

I know I did not do the right thing, and ask the admin of the website to reset the php setting to SHORT so <? be ok. and I forget about it. :cry:

However, after a year, he needs to turn the switch off. So all my php codes which started with <? will fail!! :banghead:

IF I do not have access to the admin, and I need to convert all my codes to <?php, WHAT SHOULD I DO?

I was thinking to make a macro/function or something which reset the setting to SHORT(SO <? be fine) for the current page and by using "shh" put it to the top of all php files! and forget about it!

I am not even sure this might work, but PLEASE HELP ME

THANKS :banghead:

Re: Convert <? to <?php

Posted: Thu Feb 18, 2010 4:51 am
by realnsleo
Hi,
i feel your pain. Okay carry out these instructions. It will work like a charm!
1. Download Dreamweaver and install it.
2. After installing, blah blah, open it and click on Site in the navigation menu then select New Site
3. Name your site anything, and edit the local root folder and default images folder then click Ok
4. Your site will be created, now open any file in your site folder and click Ctrl+F.
5. A find box will pop up, now enter

Code: Select all

[color=#FF0000]<?[/color]
in the Find field and

Code: Select all

[color=#FF0000]<?php[/color]
in the replace field.
6. In the Find in: select field above all the other fields, select Entire Current Local Site and click the Replace All button!

That's it. Hope this helps!

Re: Convert <? to <?php

Posted: Thu Feb 18, 2010 5:29 am
by timWebUK
What you have suggested will turn all

<?php into <?phpphp as well as <? into <?php

So once you've done that, you will need to do another find and replace and do find <?phpphp and replace that with <?php

Don't get Dreamweaver just for that, use Notepad++

Re: Convert <? to <?php

Posted: Thu Feb 18, 2010 5:31 am
by realnsleo
nice addition tim!

Re: Convert <? to <?php

Posted: Thu Feb 18, 2010 12:45 pm
by just_php
yup,
I was thinking about that
even with commend line I could replace it too.
Thanks guys.

Re: Convert <? to <?php

Posted: Thu Feb 18, 2010 2:13 pm
by manohoo
If you don't know PHP I wouldn't fool around with the code at all. There's an easier way, you can use a directive to use the short tag.

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