A method property uses an object property as default, so a method property is not used as a method property.
public function createShipment($startZip, $endZip, $weight=null){
$weight = !$weight ? $this->getDefaultWeight() : $weight;
}
// or...
public function createShipment($startZip, $endZip, $weight=null){
if ( !$weight )
$weight = $this->getDefaultWeight();
}
Tags: php parameters error-handling
Source: By cmcculloh as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0
Related code-snippets:
- How do you enable a plugin for a PHP application?
- Flat file databases are generally stored in a computer hard drive. Flat file databases cannot be shared by any party with another.
- Is Object Property accessible from within object method?
- How can you track a downloaded file?
- How do I generate a tag cloud from an array using h1 through h6 for sizing?
- Is PHP session security really that important for web?
- What are the best ways to access Exchange using PHP?
- How do you keep your email address and password private while you are surfing the net?
- Why does PHP Variable pass by value when it should be passed by reference?
- How do I debug a PHP script?
- Make Apache / XAMPP serve file outside of htdocs folder. Make XAMPP and Apache serve file outside of htdocs folder.
- How do I get authenticated user ID under Apache using PHP & HTTP Authentication?
- What are the best ways to fix duplicate error handling code in C#?
- What are some ways to get matches using preg_replace in PHP?
- Why is my ternary expression not working?