闲来将平时用的调试代码
print_r(get_class_methods(get_class($temp_object)));
稍微修改了下,然后加到了index.php 文件中,方便调试Magento时使用
如下:
- function objInfo($temp_obj){ //show object class methods data information
- $temp_class = get_class($temp_obj);
- if(!$temp_class) {
- echo "\$$temp_obj is not an object ~!<br>";
- print_r($temp_obj);
- echo "<hr>";
- return 0;
- }
- $details = '';
- $temp_methods = get_class_methods($temp_class);
- $details .= ('The Object of Class: '.$temp_class.' --totaly has '.count($temp_methods).' Methods<hr>');
- $temp_vars = get_class_vars($temp_class);
- foreach($temp_methods as $temp_method){
- $details .= ("\$object->".$temp_method."()<br>");
- }
- $details .= '<hr>';
- if(in_array('debug',$temp_methods)) {
- $details .= '<h2>debug() method returns</h2><hr>';
- $temp_data = $temp_obj->debug();
- foreach($temp_data as $_var => $_value){
- if(!is_array($_value)) $details .= ($_var.' === '.$_value."<hr>");
- else {
- $details .= $_var ." === array (";
- foreach($_value as $t_var => $t_value)
- $details .= (' ['.$t_var.' = '.$t_value.'] ');
- $details .= ')';
- }
- }
- }
- if(in_array('getData',$temp_methods)) {
- $details .= '<h2>getData() method returns</h2><hr>';
- $temp_data = $temp_obj->getData();
- foreach($temp_data as $_var => $_value){
- $details .= ($_var.' === '.$_value."<hr>");
- }
- }
- print_r($details);
- return 1;
- }//objInfo end;
使用说明,如在product/view.phtml中查看 $_product 相关可用方法
- objInfo($_product);