Both are working fine. I’m just curious how php parse the two. Do they have difference on speed, efficiency, etc. Why does php allow us to use both?
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.
if you are using just
literalphp recognizes this as aconstant. So it try to find that constant, and if it fails – it just assumes that your desire was using string literal'literal'. But, to indicate that it doesn’t found the constant it raisesNoticelevel error.So, using just
literalhave tweo drawbacks:literaldefined – you’ll get it’s value (and this is a correct usage), not string'literal'Noticeif you don’t have such constant.So, don’t use just
literalunless you have a constant with that name defined.