Jump to content

ifubad

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ifubad's Achievements

Member

Member (2/5)

0

Reputation

  1. The following interface, because it starts with "interface", is that considered as a programmer defined interface, and not PHP's predefined interface? Book I am reading is getting me confused. Thank in advance <?php interface Iterator{ public function current(); public function key(); public function next(); public function rewind(); public function valid(); } ?>
  2. cool, tried it and I understood your last reply. Thanks What do you mean by autoloading mechanism and how does it make it more difficult?
  3. Thank you, that part I do know. What I was wondering is that if it was possible to store different exception classes in a single "include" file. That way, I figured it MAY make it easier to maintain all of the custom exceptions.
  4. When using multiple catch for custom exceptions, as of now, I have the custom exception classes as separate include files. Like so Catch block catch(FileException $e){ $e->showError(); } catch(MailException $e){ $e->logError(); } custom Exception classes Filename: FileException.inc.php class FileException extends Exception{ public function showError(){ die($this->getMessage()); } } Filename: MailException.inc.php class MailException extends Exception{ public function logError(){ error_log($this->getMessage(),1,'sysadmin@domain.com'); } } Is it possible to keep the different custom exceptions in a single/central file? If so, can you provided a simple example on how to implement. Or, is it that when using multiple custom exceptions, they HAVE to be kept in separate files? TIA
  5. If I have FF3.5 installed, is FF2 different enough to be worth keeping on the system for layout testing purpose? TIA
  6. Cooool, I always wanted to pay several hundred $$$ for my copy of PHP anyway.
  7. I read some articles from 2004 saying PHP may possibly be taken over by Sun in the future? Is this just a farce? Hope the speculation stays that way
  8. Got the following first custom Exception example from w3schools. The second example is a slightly modified version, that is not using a custom Exception, and outputs exactly the same message, with slightly less code overall. As stated by somewhere explaining why use a custom exception, because "The default exception class doesn't exactly fulfill the graceful part of handling unpredictable results. It just prints out an error message not much different from regular errors." So, what is the big advantage of using a custom exception, if the more graceful message can be printed out within the echo statement of the catch block, when using the default Exception class. To produce cleaner code? Using custom Exception <?php class customException extends Exception { public function errorMessage() { //error message $errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile() .': <b>'.$this->getMessage().'</b> is not a valid E-Mail address'; return $errorMsg; } } $email = "someone@example...com"; try { //check if if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { //throw exception if email is not valid throw new customException($email); } } catch (customException $e) { //display custom message echo $e->errorMessage(); } ?> Using default Exception <?php $email = "someone@example...com"; try { //check if if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { //throw exception if email is not valid throw new Exception($email); } } catch (Exception $e) { //display custom message echo 'Error on line '.$e->getLine().' in '.$e->getFile() .': <b>'.$e->getMessage().'</b> is not a valid E-Mail address'; } ?>
  9. I finally had some free time after working an 80 hr week, taking care of my kid & painting the house, so I put aside 10 hrs and completely finished the coding & calculations for ya <?php echo 'Procrastination' . ' = ' . 'F'; ?>
  10. Ahhh, either an include or ini file, kinda like below(of course the Constants class would actually be in a different file). I guess one can either use a class as below to store the constants, or a simple include with constants created by define(). Which method of storing constants would be the preferred/correct way out of these two, using const in a class or the procedural define()? For a medium to large site, would storing lots of constants and other pertinent data in an ini file be better than an include? <?php class Constants{ const QUANTITY = 1; const EXAMPLE_CONST = "Blah blah blah"; } class ExtException extends Exception{ private $msg = "Gummy Bear"; public function __construct(){ $obj = new Constants(); $msg = Constants::QUANTITY . " " . $this->msg; parent::__construct($msg); } } try { throw new ExtException(); } catch(ExtException $e) { echo $e->getMessage(); } ?>
  11. Need a little explanation. Read this snippet in a book. Exactly what is the author suggesting, storing all the constants in what type of file? Thanks in advance
  12. using the function filter_var with the constant FILTER_VALIDATE_EMAIL seems much easier, but a lot of books talks about using regular expression instead. Any opinions would be appreciated?
  13. I read that section of the book soooo many times and it just kept confusing me. A BIG thank u for the clear explanation, now I can finally move on to the next section , hopefully there will not be any more confusing chapters later. Thnx a whole bunch, it was driving me nuts.
  14. Thanks for explaining it in a very clear way, it was easily understood. From what I gathered of what the author of the book is trying to teach, is that the reason he is suggesting to force one open connection at a time only, is mainly to conserve resources. TYPICALLY, does this resource concern justify the author's method, compared to just connecting to multiple dbases simultaneously?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.