Comments (5)
Change your code to this.
`private static function _object(&$data, $name)
{
?>
<div <?php if ((is_object($data) && count(get_object_vars($data)) > 0) || count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
class="krumo-element<?php echo (is_object($data) && count(get_object_vars($data)) > 0) || count($data) > 0 ? ' krumo-expand' : '';?>" >
<a class="krumo-name"><?php echo $name;?></a>
(<em class="krumo-type">Object</em>)
<strong class="krumo-class"><?php echo get_class($data);?></strong>
</div>
<?php if ((is_object($data) && count(get_object_vars($data)) > 0) || count($data))
{
self::_vars($data);
} ?>
</li>
<?php
}`
from krumo.
if ( is_array( $data) ) {
if ( $data > count( $data) ) // if the requested data doesn't exist
$data = count( $data); // give them the highest numbered data that DOES exist
} else {
$data= 0;
}
from krumo.
Casting
$data
to an array causes more bugs. Ideas?
This is used to render objects, so it should not be converted to array. The suggestion from @yayabla to use get_object_vars($data)
is the best approach
from krumo.
Issue is fixed in 0.4.1
from krumo.
Try this Solution:
if ( count( $_posts )) {
....
}
Add "is_array($_posts) &&" to become:
if (is_array($_posts) && count($_posts) ) {
....
}
from krumo.
Related Issues (10)
- Expand All / Collapse All
- Message: count(): Parameter must be an array or an object that implements Countable HOT 2
- Are we duplicating effort on Krumo projects? HOT 15
- count(): Parameter must be an array or an object that implements Countable HOT 1
- "How to display arguments name (variable name) in krumo listing" HOT 2
- Instead of printing output, return it to a variable HOT 1
- Print the dumps at the end of the page HOT 1
- Drop krumo.ini HOT 1
- Only prints public methods and variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from krumo.