Jump to content

questions concerning logic operators and include_path


ignace

Recommended Posts

Can someone tell me how the following works and how it is called (i can't find anything on the internet, and keywords like and and or display to many results logically):

 

mysql_query("..") or exit("..");

 

is this also possible using ||? and how does this differ from:

 

someFunction() and someFunction2();

 

again is this also possible using &&? Do just standard boolean rules apply here, like when used in an if-statement?

 

second question how does set_include_path() work if i output the include_path before setting it it is preceded with a . (dot) which refers to the current working directory (cwd), but when i do:

 

set_include_path("my/common/directory");

require_once "cwdfile.php";

 

and the file cwdfile is included because it makes sense, it first checks if the file is available in the cwd and includes it, if its not then it utilizes the include_path so why is by default the include_path preceded with a . (dot) it doesn't make sense to check if a file is in the cwd twice, does it?

 

best regards,

ignace

Link to comment
Share on other sites

It's logic.  foo() OR bar(); If foo() evaluates to false here then bar() will execute otherwise it will not. Read the following and do some tests too:

 

  http://php.net/manual/en/language.operators.logical.php

 

And I prefer an if statement here, and not 'or' because it allows for a { block } to execute more than one statement.

 

As for include_path, not sure, I was not aware of this behavior and always make sure '.' is in the include_path when wanting to include files from the cwd. I think that's a wise choice.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.