The title is in the question (EDIT: 😛 I mean the question is in the title), basically can I call variable $x before defining it further down the page?
Share
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.
I am not quite sure to understand your point but if you want to write
you will not get “2” as a result.
PHP will usually not issue a warning when you reference a variable that has not yet been assigned a value. PHP will create it on the fly and assign it the null value which will then be casted to whatever scope you have. For example
will print 5 because in this case $b will be interpreted as beeing 0.
I hope this will help
Jerome