1

I am working with phpActiveRecord as my ORM. So when I query it spits out objects. My problem is when iterating over the objects with the code I run in some objects that are empty/null or otherwise useless, which throw an exception in the form of a "Notice", which I know "Notice" isn't a make a break error, but I don't like to leave that margin of error in my code. So now Im trying to figure out how I can check to see if something like

$this->object

is empty, null, or otherwise set. I've tried

if(!isset($this->object))
if(!empty($this->object))
if(trim($this->object)!=='')

which all break it seems as I'm trying to get a property of a non-object. Which would normally imply to me I am accessing an array over an object, but thats not the case as the same $this->object works for all the results where the object actually has data

0

1 Answer 1

1

if you're trying to verify the existence of an method use method_exists() or is_callable()

EDIT

indeed, if you need to check a property of an object you can use property_exists()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.