Jump to content

ifubad

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Everything posted by ifubad

  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?
  15. Thank u for the explanation, it cleared things up a most of the way. Another Question: The example from the book is using a connection object, which uses a static variable to programmatically force it to only have one connection at a time. Is it that the main reason is to conserve resources, even though as stated by the above reply, where multiple connections is possible? (these books, sometimes when one keeps reading it over and over, it gets even more confusing) See book excerpt below.
  16. Using a single script Connecting to two dbases on different servers, must the first connection be closed first? Connecting to two dbases on the same server, must the first connection be closed first?
  17. it's centering fine as is with FF2, IE6 7 & 8. What browser r u using? also, no need to use two separate declarations for the margin, just use margin: auto; /*covers both left and right*/
  18. using display:table has problems with certain browsers, especially with some IE This is one of the better options for centering a floated list, personally, I prefer the first option on this page http://pmob.co.uk/pob/centred-float.htm
  19. If I link to a css file, and within that linked css file, it has 3 import css files @import url(/css/1.css); @import url(/css/2.css); @import url(/css/3.css); for the sake of argument, if each import file has the sale rule, but each with its own unique color Is it correct that the last file "3.css" will override the first two, since that is the last of the import? Just like if using a single css, whatever comes last will override whatever is above it.
  20. floated elements cannot be centered easily, there is a simple trick for it, read here http://pmob.co.uk/pob/centred-float.htm
  21. if that fixes your problem and save you a big headache, and you still want to shoot some dough over that you don't want anymore, I sure can use it...
  22. if this has to do with a:hover, the IE6 hover bug may require a trigger, like a:hover { font-size: 100%; } if font-size does not work, try color:whateverColor, or float:none, or border:none, and so on until you find one that works. The trigger point is different depending on how your overall code is. google for "ie6 hover bug".
  23. Pardon my French, than I guess you're f**ked. But, that's not a French word.
  24. can't be 100% sure, but that was the ONLY site (imagebam.com) I checked out that would even pull anything like that. I google imagebam.com, found this on a yahoo group, happened to others also and imagebam also admitted it, guess it just depends on which ad you just happen to get on the page, and for me, I hit the lotto: http://groups.google.com/group/imagebam/browse_thread/thread/bccf7410ea70bf49#
×
×
  • 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.