Re: PHP 5 && OO && performance && exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
To: <cron@xxxxxxxxxx>
Sent: Wednesday, November 09, 2005 1:37 PM
Subject: Re:  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@xxxxxxxxxx <cron@xxxxxxxxxx> 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






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux