|
Posted by Oliver Grδtz on 08/24/05 05:20
NC schrieb:
> Fortunately, we are not there yet. OOP can still be avoided
> if necessary. Reading a remote file still can be done in a
> single file_get_contents(),
OOP always seems to be "the bad guy". Sure, I like file_get_contents(),
especially if it's "file_get_contents('http://www.google.com');", but
what is so bad with
$myfile=new File('my-article.txt');
foreach($myfile as $line)
{
// do stuff
}
> as opposed to spawning a
> HttpWebRequest/WebResponse pair in VB.NET. Most importantly,
> string is still not an object.
What is so bad about
$s=new String('this is a test');
echo $s->reverse();
against
$s='this is a test';
echo strrev($s);
It's absolutely the same. But the String class could tell you about it's
capabilities:
print_r(get_class_methods('String'));
The only thing bad about strings being objects is having to write more
code. In Ruby this isn't true, since strings are first class objects and
you can actually call methods on the strings:
print "this is a test".reverse
Even numbers are objects and they've got handy methods:
5.times print "Hello."
Objects are good. Period.
AllOLLi
Navigation:
[Reply to this message]
|