Jump to content

True / False Evaluation Questions


timothyarden

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/273903-true-false-evaluation-questions/
Share on other sites

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 :)

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.