You are here: Re: [PHP] PHP 5 && OO && performance && exceptions « PHP « IT news, forums, messages
Re: [PHP] PHP 5 && OO && performance && exceptions

Posted by cron on 11/10/05 23:47

I was not considering that, I was using $obj_string->getValue(), the
__toString method and type casting could save me some keystrokes :)



Anyway, did you abandon the development with the basic types class?



Angelo



----- Original Message -----
From: "Jake Gardner" <gardner.jake@gmail.com>
To: <cron@odi.com.br>
Sent: Wednesday, November 09, 2005 1:37 PM
Subject: Re: [PHP] PHP 5 && OO && performance && exceptions


I myself was considering creating classes such as String, but I ran
into more basic problems before performance, for example:

class String {
protected $Value;
function __construct($Value) {
$this->Value = $Value;
}
}
$SomeString = new String("Hello World!");
Print($SomeString); // Does not print "Hello World!"

The way around this was still unsatisfactory:
class String {
protected $Value;
function __construct($Value) {
$this-> Value = $Value;
}
function __toString() {
return $this->Value;
}
}
$SomeString = new String("Hello World!");
Print($SomeString); // Prints "Hello World!"

Because this has obvious limitations, and is only a fix for strings;
this doesnt work for functions that expect integer values.

In reality, there really is no way to use PHP to rewrite a type in PHP
without using the PHP "omni-type".

However, you can use type casting as it is:

http://us2.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting

http://us2.php.net/manual/en/function.settype.php


On 11/9/05, cron@odi.com.br <cron@odi.com.br> wrote:
> Hello,
>
>
>
> Currently I'm make some utilities classes and I took the idea from java to
> make some wrappers class like String, Integer and so on. This allows me to
> use the type hint for basic types in php. Anyone have a clue if replacing
> the all in one type in php for objects types will degrade the performance?
>
>
>
> Also for every controller class that I'm making I'm also making exceptions
> class of every error that it can generate. Same questions: It will
> degrade performance to throw an exception instead of lest say a pear error
> or return false?
>
>
>
> Just for know, I'm doing this because I believe that it will eliminate
> some o problems o development and will eliminate some basic validations.
>
>
>
>
>
> Any tips appreciate
>
>
>
> Angelo
>
>
>
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация