colB Posted October 16, 2007 Share Posted October 16, 2007 I recently installed WAMP5 from wampserver on my work PC (winXP) and have been stumped by a problem that I am assuming is some sort of issue between the wamp config and the OS config. When I try to run the following code, instead of 'Bang!', I get 'bar(); ?>'. It seems that everything after the -> operator is ignored. Initially I though this was a newbie coding error, but I installed an identical wamp5 setup on my home PC (win2k) and everything works as it should on that system. the code: <?php class foo { public function bar() { print "Bang!\n"; } } $anInstance = new foo; $anInstance -> bar(); ?> Can anyone suggest what OS settings, or security controls might cause this sort of behaviour? Or any other potential cause. thanks Col Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/ Share on other sites More sharing options...
trq Posted October 16, 2007 Share Posted October 16, 2007 That is wierd, Id'e try it without the space though, see how this goes. <?php class foo { public function bar() { print "Bang!\n"; } } $anInstance = new foo; $anInstance->bar(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-370858 Share on other sites More sharing options...
colB Posted October 16, 2007 Author Share Posted October 16, 2007 That is wierd, Id'e try it without the space though, see how this goes. White space shouldn't (and doesn't) make any difference. Is outputting the rest of the code as text the normal PHP response to "I don't understand this code". Or would it have to be something more specific like recognizing '->' as an alias of '?>' ? Col Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-370886 Share on other sites More sharing options...
wildteen88 Posted October 16, 2007 Share Posted October 16, 2007 When you run that script right click and select view source, do you see your PHP source code? If you do then either WAMP is not configured correctly or you are not using the write file extension in order for WAMP to parse your PHP scripts. I can confirm its a configuration issue as if I change the start php tag (<?php) to <? I get bar(); ?>. If I enabled short_open_tags then the code words as expected. Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-370892 Share on other sites More sharing options...
colB Posted October 16, 2007 Author Share Posted October 16, 2007 When you run that script right click and select view source, do you see your PHP source code? If you do then either WAMP is not configured correctly or you are not using the write file extension in order for WAMP to parse your PHP scripts. I can see the source code when I open the file in a web browser and choose view source. Wamp is using its defaults which work fine on my home system. As far as file extensions, I'm using PHPeclipse on both systems with whatever extension it uses for php files. I can confirm its a configuration issue as if I change the start php tag (<?php) to <? I get bar(); ?>. If I enabled short_open_tags then the code words as expected. That's very useful to know - at least I can concentrate on the configuration, tyvm. Col Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-370949 Share on other sites More sharing options...
wildteen88 Posted October 16, 2007 Share Posted October 16, 2007 How are you running the php script in the browser? Make sure you wamp is running and you are going to http://locahost/ to run your script. Also make sure you save your script in C:/wamp/www/ (change the to path of where WAMP is installed to). You can not run your PHP scripts directly through the browser, like you can with HTML files for example. Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-370981 Share on other sites More sharing options...
colB Posted October 16, 2007 Author Share Posted October 16, 2007 How are you running the php script in the browser? Make sure you wamp is running and you are going to http://locahost/ to run your script. Also make sure you save your script in C:/wamp/www/ (change the to path of where WAMP is installed to). You can not run your PHP scripts directly through the browser, like you can with HTML files for example. I'll double check all that stuff tomorrow when I'm back on the work system. I did get it all working here on my home system with no trouble whatsoever - here I can run the php file from eclipse or through my browser directly using http://localhost/myfolder/myfile.php (I didn't even try C:\wamp\www\myfolder\myfile.php). I've done a little php stuff in the past - setting up AMP by hand and heavily customizing some joomla plugin. But I don't 'know' php the way I know c++ and java in terms of how stuff works behind the scenes, so I don't have any intuition when things don't work as they should. Thanks for your help, and I'll post back when I've had a chance to try some of these suggestions. Col Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-371037 Share on other sites More sharing options...
colB Posted October 17, 2007 Author Share Posted October 17, 2007 It was down to me using the local file path rather than localhost I still havn't got things working at I want in eclipse, but at least I can successfully run my php in an external browser, so I can get some work done. Thanks for the help Col Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-371437 Share on other sites More sharing options...
wildteen88 Posted October 17, 2007 Share Posted October 17, 2007 When setting up eclipse with PHP I used this guide. Quote Link to comment https://forums.phpfreaks.com/topic/73472-solved-php-ignoring-code-after-operator/#findComment-371729 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.