cucumber Posted May 20, 2007 Report Share Posted May 20, 2007 Pec manuala sanak ka nevar un shitais http://www.php.net/manual/en/language.exceptions.php#74854 variants ar nesanca. Var but ir kads hack, ka lai isauc exeption'u ieksh __destruct'ra? vai Labak uzrakstit savu erroru keraju? Link to comment Share on other sites More sharing options...
bubu Posted May 20, 2007 Report Share Posted May 20, 2007 Man šāds kods: <?php class KLASE { function __construct() { echo "konstruktors\n"; } function __destruct() { echo "pirms throw\n"; throw new Exception("exceptions"); echo "peec throw\n"; } } $x = new KLASE(); try { echo "pirms null\n"; $x = null; echo "peec null\n"; } catch (Exception $e) { echo "Nokjerts: " . $e->getMessage() . "\n"; } ?> Izdrukā tieši to, ko gaidīju: konstruktors pirms null pirms throw Nokjerts: exceptions Tu laikam pārprati manuāli - gan jau, ka tur ir domāts, ka nedrīkst mest exceptionu, ja neviens to nenoķers. Tāpēc, ja tev ir apkārt catch, tad viss būs ok. Link to comment Share on other sites More sharing options...
Delfins Posted May 21, 2007 Report Share Posted May 21, 2007 Labak uzrakstit savu erroru keraju? catch-i priekš tā arī domāti lai ķertu Exception-us un nepieļaut programmas "izlidojumus"/neparedzētus gājienus Link to comment Share on other sites More sharing options...
cucumber Posted May 21, 2007 Author Report Share Posted May 21, 2007 (edited) Tik tiesham to var izdarit, man bija kluda un php radija ka vinsh nekada veida nevar izpildit throw, tapec ta radija, bet tagad ir otra problema, palaizot kaut vai bubu doto scriptu uz lokala servera man rada file transfering, tas ir page pie parlades sakuma aiziet lidz kaut kur 30%, tad pastav kadas 1-2sec un tad aiziet uzreizs lidz galam (lapa ieladeta), kas var but par problemu. ka tas izskatas Edited May 21, 2007 by cucumber Link to comment Share on other sites More sharing options...
bubu Posted May 21, 2007 Report Share Posted May 21, 2007 Es to skriptu manā postā nelaidu no webservera. Es to laidu konsolē: php.exe fails.php. Varbūt tomēr no webservera nevar mest exeptionus kā pagadās destruktorā... nez. Slinkums webserveru instalēt. Link to comment Share on other sites More sharing options...
john.brown Posted May 21, 2007 Report Share Posted May 21, 2007 Var, viss notiek. cucumber, viss tak tev tur it kā normāli iet. Tu kaut kā bik sakarīgāk trablu apraksti... Link to comment Share on other sites More sharing options...
Recommended Posts