Why can I not do something like the following when I know that the property of myobject is going to be declared already:
define('title','boats');
myobject->title;
but this works:
myobject->boats
Is this even good practice?
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.
You can’t use
as this is attempting to access the
titleproperty of your object. If this property does not exist, an error will be triggered.You can use
but I’d rather see you use a variable instead of a constant, eg
Ideally, you will know which property you want to access and use its name appropriately