असल में मैं कोड इग्निटर का उपयोग कर रहा हूं, और कोड इग्निटर बेस क्लास बहुत बड़ा है, जब मैं अपनी कुछ वस्तुओं को प्रिंट करता हूं तो उनके अंदर एम्बेडेड बेस क्लास होता है। इससे मुझे वह जानकारी मिलती है जो मैं वास्तव में चाहता था (शेष गुण)।print_r या ऑब्जेक्ट से निजी संपत्ति को बाहर कर दें?
तो, मुझे आश्चर्य है कि क्या कोई रास्ता है जिसे मैं छुपा सकता हूं, या बेस क्लास ऑब्जेक्ट को हटा सकता हूं?
मैं
clone $object;
unset($object->ci);
print_r($object);
की कोशिश की है लेकिन निश्चित रूप से ci संपत्ति निजी है।
वास्तविक समारोह मैं डंपिंग के लिए उपयोग कर रहा हूँ है:
/**
* Outputs the given variables with formatting and location. Huge props
* out to Phil Sturgeon for this one (http://philsturgeon.co.uk/blog/2010/09/power-dump-php-applications).
* To use, pass in any number of variables as arguments.
* Optional pass in "true" as final argument to kill script after dump
*
* @return void
*/
function dump() {
list($callee) = debug_backtrace();
$arguments = func_get_args();
$total_arguments = count($arguments);
if (end($arguments) === true)
$total_arguments--;
echo '<fieldset style="background: #fefefe !important; border:2px red solid; padding:5px">';
echo '<legend style="background:lightgrey; padding:5px;">' . $callee['file'] . ' @ line: ' . $callee['line'] . '</legend><pre>';
$i = 0;
foreach ($arguments as $argument) {
//if the last argument is true we don't want to display it.
if ($i == ($total_arguments) && $argument === true)
break;
echo '<br/><strong>Debug #' . (++$i) . ' of ' . $total_arguments . '</strong>: ';
if ((is_array($argument) || is_object($argument)) && count($argument)) {
print_r($argument);
} else {
var_dump($argument);
}
}
echo '</pre>' . PHP_EOL;
echo '</fieldset>' . PHP_EOL;
//if the very last argument is "true" then die
if (end($arguments) === true)
die('Killing Script');
}
लेकिन मैं अन्य निजी संपत्तियों चाहते हैं, मैं तो बस @Hailwood है कि एक संपत्ति – Hailwood
अब थोड़े hacky तरह से प्रयास करते हैं, नहीं चाहते हैं, लेकिन हो सकता है काम। – arma
लेकिन 'get_object_vars() 'ऑब्जेक्ट को पैरामीटर के रूप में अपेक्षा करता है। '$ class_of_object' एक स्ट्रिंग है। – TheFox