Created
March 8, 2015 08:49
-
-
Save steveathon/09cab0e6ce27ad864de5 to your computer and use it in GitHub Desktop.
IF Resource Evaluation test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $ch = curl_init() && curl_setopt($ch,CURLOPT_AUTOREFERER,FALSE) ) { | |
echo "Passed this test.\r\n"; | |
} | |
else { | |
echo "Failed this test.\r\n"; | |
} | |
class moo { | |
function test() { | |
if ($this->ch = curl_init() && curl_setopt($this->ch,CURLOPT_AUTOREFERER,FALSE) ) { | |
echo "Passed this test.\r\n"; | |
} | |
else { | |
echo "Failed this test.\r\n"; | |
} | |
} | |
} | |
$Moo = new moo(); | |
$Moo->test(); | |
?> | |
All of these tests above fail with the erorr, that there is no valid resource on $ch available to setopt functions. | |
With that in mind, switching it to OR, in the form of: | |
<?php | |
if ( $ch = curl_init() | |
|| curl_setopt($ch,CURLOPT_AUTOREFERER,FALSE) ) { | |
echo "Passed this test.\r\n"; | |
} | |
else { | |
echo "Failed this test.\r\n"; | |
} | |
?> | |
Passes the test. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As an aside, wrapping the call inside another bracket works: