Here's a handy little routine I just wrote to suggest properties you're
trying to erroneously set that don't exist in a class. For example:

Attempted to __get() non-existant property/variable 'operator_id' in class
'User'.
 
checking for operator and suggesting the following:
 
    * id_operator
    * operator_name
    * operator_code
 
enjoy.
 
 /**
  * Suggests alternative properties should a __get() or __set() fail
  *
  * @param  string $property
  * @return string
  * @author Daevid Vincent [dae...@daevid.com]
  * @date    05/12/09
  * @see  __get(), __set(), __call()
  */
 public function suggest_alternative($property)
 {
  $parts = explode('_',$property);
  foreach($parts as $i => $p) if ($p == '_' || $p == 'id')
unset($parts[$i]);
 
  echo 'checking for <b>'.implode(', ',$parts)."</b> and suggesting the
following:<br/>\n";
 
  echo "<ul>";
     foreach($this as $key => $value)
   foreach($parts as $p)
    if (stripos($key, $p) !== false) print '<li>'.$key."</li>\n";
  echo "</ul>";
 }
 
just put it in your __get() or __set() like so:
 
 public function __get($property)
 {
      echo "<p><font color='#ff0000'>Attempted to __get() non-existant
property/variable '".$property."' in class
'".$this->get_class_name()."'.</font><p>\n";
   $this->suggest_alternative($property);
   exit;
 }


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to