Are you a Windows user trying out Feisty Fawn? Point and click to access your Windows files within Ubuntu in under a minute!
Ubuntu 7.04 can read and write files on the NTFS drives commonly used by Windows.
Technology, Software, Linux and System Administration
Are you a Windows user trying out Feisty Fawn? Point and click to access your Windows files within Ubuntu in under a minute!
Ubuntu 7.04 can read and write files on the NTFS drives commonly used by Windows.
I was confident that using one of php5′s magic methods, __toString() would just work, but the fact is that the following code works in php version 5.2.1 but not in 5.1.6:
You can try this for yourself:
<?php
class ToStringTest {
protected $content;
public function __construct($content) {
$this->content = $content;
}
public function add($content) {
$this->content .= $content;
}
public function __toString() {
return $this->content;
}
}
$A = new ToStringTest('Hello, ');
$A->add('World!');
echo $A . "\n";
$
$B = new ToStringTest('Say ');
$B->add( $A );
echo $B . "\n";
?>
In php 5.2.1, output is:
Hello, World! Say Hello, World!
and in php 5.1.6
Hello, World! Say Object id #1
And then it hit me:
It is worth noting that before PHP 5.2.0 the __toString method was only called when it was directly combined with echo() or print().
Small piece of advise: always be sure to know what is a certain function’s behavior in the possible php versions your code will be running, or risk bad surprises.
Meanwhile… use something like
$SomeObject->_toString();
These are some really useful tips from Tom Johnson’s I’d rather be writing. I think the post, entitled “Twenty Usability Tips for Your Blog” covers most of what should be said about the best practices of blogging.
Continue reading ‘Top usability tips bloggers must know about.’