I want to do something like this without using extra variables:
class className {
public static function func(){
return array('true','val2');
}
}
if(className::func()[0]) {
echo 'doğru';
} else {
echo 'Yanlış';
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
className::func()[0]is called array dereferencing, and is not valid syntax in all PHP versions. Itwill beis available starting in PHP 5.4,currently in beta, released March 2012. For earlier PHP version, you will need to use an extra variable somewhere to store the array returned fromclassName::func().See the PHP 5.4 Array documentation for implementation details.