Convert <? to <?php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
just_php
Forum Newbie
Posts: 2
Joined: Thu Feb 18, 2010 4:28 am

Convert <? to <?php

Post 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:
realnsleo
Forum Newbie
Posts: 15
Joined: Sat May 16, 2009 12:08 pm

Re: Convert <? to <?php

Post 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!
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: Convert <? to <?php

Post 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++
realnsleo
Forum Newbie
Posts: 15
Joined: Sat May 16, 2009 12:08 pm

Re: Convert <? to <?php

Post by realnsleo »

nice addition tim!
just_php
Forum Newbie
Posts: 2
Joined: Thu Feb 18, 2010 4:28 am

Re: Convert <? to <?php

Post by just_php »

yup,
I was thinking about that
even with commend line I could replace it too.
Thanks guys.
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Convert <? to <?php

Post 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
Post Reply