timothyarden Posted February 1, 2013 Share Posted February 1, 2013 Hi Freaks, Just some quick questions: 1) Assuming the function test() returns a true or false value, would these two pieces of code process the same? (if not could you please explain why) if(test()){ // action(s) } //and if(test() === true){ //action(s) } 2) Same question except for false: if(!test()){ // action(s) } //and if(test() === false){ //action(s) } 3) if the function returned a string / integer / array / true on success or false on failure would the actions in the if loop execute? (assuming that the function test returned success and therefore was a string / integer / array / true): if(test()){ // action(s) } Thanks for reading and for everyones help in advance. I know this kind of post would generally be responded to with go try it for yourself but my XAMPP has currently been not allowing me to turn on Apache because of an error. Timothy Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/ Share on other sites More sharing options...
trq Posted February 1, 2013 Share Posted February 1, 2013 Or, you could look at the manual. http://php.net/bool Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409478 Share on other sites More sharing options...
timothyarden Posted February 1, 2013 Author Share Posted February 1, 2013 Thanks for the link trq. That answers the first question and I assume it is the same for the second? Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409479 Share on other sites More sharing options...
trq Posted February 1, 2013 Share Posted February 1, 2013 It should answer all of your questions. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409480 Share on other sites More sharing options...
timothyarden Posted February 1, 2013 Author Share Posted February 1, 2013 Sorry, yep your right. Thanks for your time and help Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409481 Share on other sites More sharing options...
Jessica Posted February 1, 2013 Share Posted February 1, 2013 Plus, the most effective way to find out "does this do that?" Is to... Do it. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409485 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 Thanks for the advice Jessica, but as I said in my first post XAMPP's Apache process won't start. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409651 Share on other sites More sharing options...
DavidAM Posted February 2, 2013 Share Posted February 2, 2013 You can run PHP scripts from the command-line as well --- no Apache needed. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409656 Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 Hell, in 5.4 php has a web server built in. No need for Apache or Nginx anymore for development. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409663 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 You can run PHP scripts from the command-line as well --- no Apache needed. Hi David, I am coding on a Windows 8 PC. Are you sure I can run it from the command line? (I assume you mean command prompt) And I thought you couldn't install PHP on Windows PC trq? Thanks for the help and advice guys Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409664 Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 And I thought you couldn't install PHP on Windows PC trq? What makes you think that? Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409666 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 Thats what I was told by a friend who does PHP Development Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409667 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 I thought it was only able to be run on Linux and ASP on PCs? Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409668 Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 PHP is cross platform. Most hosting is Linux. It's not something I would recommend (I wouldn't recommend Windows for anything though) but a lot of people still develop locally on Windows. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409674 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 Okay, thanks for that info trq. Really appreciated Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409700 Share on other sites More sharing options...
Jessica Posted February 2, 2013 Share Posted February 2, 2013 If you want to do PHP development and your development environment is not working, I would make that priority # 1 Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409712 Share on other sites More sharing options...
DavidAM Posted February 2, 2013 Share Posted February 2, 2013 If you installed XAMP on Windows, then you have PHP installed on Windows. I have LAMP running on a Windows 7 machine at work -- I don't recommend Windows for this either, but that's what I have to work with there. I run PHP scripts from the command line (command prompt) all the time. I have even put a couple in the Task Scheduler. Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409731 Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 If you really must use Windows, I would recommend using vagrant to build a decent dev environment. See http://www.vagrantup.com Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409791 Share on other sites More sharing options...
timothyarden Posted February 2, 2013 Author Share Posted February 2, 2013 Okay, Thanks Quote Link to comment https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/#findComment-1409792 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.