Code Help

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
rwfnetworking
Forum Newbie
Posts: 4
Joined: Sat Jan 01, 2011 12:01 am

Code Help

Post by rwfnetworking »

Hey All

I'm a relatively new to PHP, but having several web sites running on PHP, I have seen tons of code from various developers so I am now diving into converting old PHP 4 application that I really like that is not PHP 5 friendly. Right off the bat, I noticed that all the Php declaration started with "<?" and not "<?php". This caused some issues, but i later learned that I could set the short_open_tag = On in my php.ini, but from what I have read it is better to leave that off. My biggest problem are some statements such as:

<SCRIPT SRC="<?=$sitepath?>checkfields.php" LANGUAGE="JavaScript"></SCRIPT>

I'm assuming that the <? and ?> are definitely php declarations, is that correct? Assuming that if I change such a statement to:

<SCRIPT SRC="<?php =$sitepath?>checkfields.php" LANGUAGE="JavaScript"></SCRIPT>

I get an error stating "Parse error: syntax error, unexpected '=' in [xxx.php] location. What does the "=" represent? From what I know about the app, it was written during the days of PHP 4



Thanks,


Robert
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: Code Help

Post by anantha »

instead of = you have to substitute with echo
rwfnetworking
Forum Newbie
Posts: 4
Joined: Sat Jan 01, 2011 12:01 am

Re: Code Help

Post by rwfnetworking »

anantha wrote:instead of = you have to substitute with echo
Thanks, is not the "=" just a shortcut for echo?


Robert
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: Code Help

Post by phazorRise »

rwfnetworking wrote:
anantha wrote:instead of = you have to substitute with echo
Thanks, is not the "=" just a shortcut for echo?


Robert
yes, it's just a shorcut for writing echo ("").. It's same as of '<%= %> ' = Response.Write() in ASP.
rwfnetworking
Forum Newbie
Posts: 4
Joined: Sat Jan 01, 2011 12:01 am

Re: Code Help

Post by rwfnetworking »

phazorRise wrote:
rwfnetworking wrote:
anantha wrote:instead of = you have to substitute with echo
Thanks, is not the "=" just a shortcut for echo?


Robert
yes, it's just a shorcut for writing echo ("").. It's same as of '<%= %> ' = Response.Write() in ASP.
So why does the shortcut generate that error message, but the full command does not? From the PHP Manual it states that both syntax's are supported in PHP 4 and 5 so one would think that the code would work ok, but at this point it doesn't unless I change the = to echo.


Robert
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: Code Help

Post by phazorRise »

prensil wrote:'=' is used as short form of 'echo' but it is only used with php short tags "<? ?>". php full form tags "<?php ?>" doesn't support '=' as echo, it considers it as operator.

Thanks & Regards,
Prensil Technologies Pvt. Ltd.
php web development company
http://www.prensil.com
Right. <? ?> and <?php ?> are equal. but <?= ?> equals to echo. and '=' is operator when used in <?php ?>.
rwfnetworking
Forum Newbie
Posts: 4
Joined: Sat Jan 01, 2011 12:01 am

Re: Code Help

Post by rwfnetworking »

Thanks for all the help. I have managed to correct about 300 lines of code, but unfortuntely the app does not work now. A little history, this is an old app called Ezupload Pro, It is an app that would allow clients to upload files to your web site. It appears to no longer be a supported commercial application and the Developer is on where to be found, but since I had bought this years ago, I wanted to see if I could get it to run under PHP 5. At present with the coding corrected as suggested, andI get no errors, but I am unable to upload any files or go through hte application provided Control Panel to make changes to any settings. Any thoughts on how to debug this? I already have my php.ini configured to display errors, but none are ever displayed. All that happens when I either try to upload a file or make changes in the application control panel is hte screen clears and refreshes.



Robert
Post Reply