Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment PHP advice legitimity (Score 1) 106

I'm no PHP guru, but reading some of their advice on PHP made me flinch.

Don't copy variables for no reason.

Sometimes PHP novices attempt to make their code "cleaner" by copying predefined variables to variables with shorter names. What this actually results in is doubled memory consumption, and therefore, slow scripts. In the following example, imagine if a malicious user had inserted 512KB worth of characters into a textarea field. This would result in 1MB of memory being used!

BAD:
$description = $_POST['description'];
echo $description;

GOOD:
echo $_POST['description'];

Now I would never question the almighty Google, but the Rasmus Lerdorf taught me that PHP uses copy-on-write. Quoting from his O'Reilly Programming PHP book:

When you copy a value from one variable to another, PHP doesn't get more memory for a copy of the value. Instead, it updates the symbol table to say "both of these variables are names for the same chunk of memory."

So who's right? I tend to believe M. Lerdorf since he pretty much invented PHP but like I said before I'm not an expert and my book is pretty old so (PHP 4.1.0) so maybe that has changed since (although I doubt it)...

Comment Install The Gorilla on it (Score 1) 544

If you're into gaming just buy an adapter to connect your laptop to a TV and a couple game controllers and install The Gorilla on your PC. That way you can turn your broken laptop into a ghetto retro gaming system with an interface you can navigate using only a gaming controller.

(Unfortunately the guy who created The Gorilla apparently died about 2 years ago so don't expect any updates soon...)
Power

Using Sun's Energy to Split Water Means Solar Power All Night 557

phorm writes "Reuters is carrying an article about a recent MIT development which may pave the way for solar-energy to be collected for use in low-input periods. According to Reuters, the discovery of the a new catalyst for separating hydrogen+oxygen from water requires only 10% of the electricity of current methods. This would allow storage-cells to function as a form of battery for other forms of energy-collection, such as solar panels. The new method is also much safer (and likely environmentally friendly) than current methods, which require the use of a dangerously caustic environment, and specialized storage containers." sanjosanjo points out coverage of the process at EE Times, which features the MIT group's press release.

Slashdot Top Deals

And it should be the law: If you use the word `paradigm' without knowing what the dictionary says it means, you go to jail. No exceptions. -- David Jones

Working...