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
Code Help
Moderator: General Moderators
Re: Code Help
instead of = you have to substitute with echo
-
rwfnetworking
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 01, 2011 12:01 am
Re: Code Help
Thanks, is not the "=" just a shortcut for echo?anantha wrote:instead of = you have to substitute with echo
Robert
- phazorRise
- Forum Contributor
- Posts: 134
- Joined: Mon Dec 27, 2010 7:58 am
Re: Code Help
yes, it's just a shorcut for writing echo ("").. It's same as of '<%= %> ' = Response.Write() in ASP.rwfnetworking wrote:Thanks, is not the "=" just a shortcut for echo?anantha wrote:instead of = you have to substitute with echo
Robert
-
rwfnetworking
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 01, 2011 12:01 am
Re: Code Help
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.phazorRise wrote:yes, it's just a shorcut for writing echo ("").. It's same as of '<%= %> ' = Response.Write() in ASP.rwfnetworking wrote:Thanks, is not the "=" just a shortcut for echo?anantha wrote:instead of = you have to substitute with echo
Robert
Robert
- phazorRise
- Forum Contributor
- Posts: 134
- Joined: Mon Dec 27, 2010 7:58 am
Re: Code Help
Right. <? ?> and <?php ?> are equal. but <?= ?> equals to echo. and '=' is operator when used in <?php ?>.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
-
rwfnetworking
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 01, 2011 12:01 am
Re: Code Help
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
Robert