As of September 2013, the repository has been moved from this Github Gist (hakre/1102761) over to a public Github repository in my account. You can find it now here:
Please visit that address for more information, updates and code.
As of September 2013, the repository has been moved from this Github Gist (hakre/1102761) over to a public Github repository in my account. You can find it now here:
Please visit that address for more information, updates and code.
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
<?php | |
define('ITERATIONS', 10000000); | |
$var = 0; | |
$start = microtime(true); | |
$var = 0; | |
while ($var < ITERATIONS) { | |
++$var; | |
} |
Paste in SO chat room console bro: | |
(function() { | |
"use strict"; | |
var chat = document.getElementById('chat'); | |
function parseNode(node) { | |
if (node.classList | |
&& node.classList.contains('message') | |
&& !node.classList.contains('pending') | |
&& !node.querySelector('.onebox') |
***Notice:*** There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future.
>Notice: There is no more support for mysql_*
functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.
javascript:document.location.href=document.querySelector("a[rel=prev]").href |
javascript:setInterval(function(){d=document.querySelectorAll('div'); | |
l=d.length;a=d[parseInt(Math.random()*l)];b=d[parseInt(Math.random()*l)]; | |
c=a.innerHTML;a.innerHTML=b.innerHTML;b.innerHTML=c;}, 42) |
document.body.removeChild(document.querySelector('.blogger-clickTrap')) |
String.prototype.abbr = function() {return this.replace(/[aeiou]+/g,'')}; | |
//eg: | |
'people'.abbr() |
Number.prototype.fee=function(fee){return /%$/.test(fee)?this-this*parseInt(fee)/100:this-fee} | |
/* | |
// 5 off | |
parseInt('100').fee(5) | |
// 15% off |