0

I am having difficulty understanding the proper syntax for the second default value in the following method declaration statement. Any suggestions would be greatly appreciated. Thanks!

protected function load($columName = self::_tableIdName, $columnValue = self::_data->{self::_tableIdName}) 
{...}

Notes: $_tableIdName is a protected variable within the class; $_data is a protected stdClass object within the class.
I am trying to make the default for $columnValue equal to the corresponding value from the internal $_data object.

1
  • FYI, did you mean $columnName as the first parameter to the load function? You put $columName. Commented Sep 30, 2011 at 21:20

1 Answer 1

5

Just set the defaults to null, then check for null in the function body. You are limited to using constants in the argument intializer.

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

1 Comment

Well that now that you say it, I guess that should have obvious. Thanks much.

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.