php-general Digest 3 Feb 2009 16:27:23 -0000 Issue 5938
php-general Digest 3 Feb 2009 16:27:23 - Issue 5938 Topics (messages 287557 through 287565): Re: PHP Linux/Windows Outlook 2003 HTML email problem 287557 by: German Geek Visibility of class constant 287558 by: leledumbo 287563 by: Chris Scott Throwing an exception seems to defeat output buffering 287559 by: Leif Wickland 287561 by: Ondrej Kulaty 287562 by: Colin Guthrie Re: How can I do the opposite of property_exists(), maybe a creat_property() in PHP5? 287560 by: Edmund Hertle 287564 by: Jochem Maas calculate the time that day ends 287565 by: Thodoris Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- It seems like this solves the issue: http://pear.php.net/bugs/bug.php?id=12032 Sorry, just hadn't found this before. Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Feb 2, 2009 at 7:24 PM, Chris dmag...@gmail.com wrote: German Geek wrote: Hi All, We've got a problem with our Ubuntu Linux machine sending HTML emails to Outlook 2003: It's an Ubuntu Server (uname -a Linux CDR2-221 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686 GNU/Linux) with the newest version of Postfix installed as the Mail server. Unfortunately, all emails sent as HTML, using the PEAR library for sending email like so: Best place to look at this would be the pear list: http://pear.php.net/support/lists.php -- Postgresql php tutorials http://www.designmagick.com/ ---End Message--- ---BeginMessage--- I got a weird behaviour of class constant. Suppose I have Index_Controller and Another_Controller classes, both extending Controller class. I define some constants (let's assume I only have one, call it MY_CONST) in Controller class to be used by its descendants. In Index_Controller, I can freely use MY_CONST without parent:: needed. However, this isn't the case with Another_Controller. Without parent:: I got notice Use of undefined constant MY_CONST - assumed 'MY_CONST'. How could this happen and what's the correct behaviour? It's actually nicer to have it without parent::, assuming that constants have protected visibility specifier (which isn't possible AFAIK :-( ). -- View this message in context: http://www.nabble.com/Visibility-of-class-constant-tp21803985p21803985.html Sent from the PHP - General mailing list archive at Nabble.com. ---End Message--- ---BeginMessage--- -Original Message- From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] Sent: 03 February 2009 05:03 To: php-gene...@lists.php.net Subject: [PHP] Visibility of class constant I got a weird behaviour of class constant. Suppose I have Index_Controller and Another_Controller classes, both extending Controller class. I define some constants (let's assume I only have one, call it MY_CONST) in Controller class to be used by its descendants. In Index_Controller, I can freely use MY_CONST without parent:: needed. However, this isn't the case with Another_Controller. Without parent:: I got notice Use of undefined constant MY_CONST - assumed 'MY_CONST'. How could this happen and what's the correct behaviour? It's actually nicer to have it without parent::, assuming that constants have protected visibility specifier (which isn't possible AFAIK :-( ). You cannot access a class constant just by the constant name. See http://docs.php.net/manual/en/language.oop5.paamayim-nekudotayim.php. you need to use self::MY_CONST, I guess; your code might make it clearer. e.g. class Controller { const CONSTANT = 'foobr /'; } class Index_Controller extends Controller { public function __construct() { echo CONSTANT; echo 'br/'; // gives warning echo self::CONSTANT; // foo echo parent::CONSTANT;// foo } } class Another_Controller extends Controller { const CONSTANT = 'barbr /'; public function __construct() { echo self::CONSTANT; // bar echo parent::CONSTANT;// foo } } new Index_Controller would give you the warning you described for CONSTANT and return 'foo' for self::CONSTANT and parent::CONSTANT as CONSTANT was inherited. In Another_Controller CONSTANT is overridden so self::CONSTANT would be 'bar' and parent::CONSTANT would be 'foo'. ---End Message--- ---BeginMessage--- I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the
[PHP] Re: Throwing an exception seems to defeat output buffering
Output buffer is flushed at the end of script. When you throw that exception in try block, this command: exit( 'Contents: ' . ob_get_clean()); never executes and it continues to catch block where you are outputing exception message, and it is added to the buffer, then the script ends and buffer flushes. === Leif Wickland leifwickl...@gmail.com pí¹e v diskusním pøíspìvku news:c5b9ee2c0902022202v6e2a071emfb062aa868ed7...@mail.gmail.com... I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? Is there a workaround? Thank you, Leif Wickland -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Throwing an exception seems to defeat output buffering
'Twas brillig, and Leif Wickland at 03/02/09 06:02 did gyre and gimble: I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? Is there a workaround? This is intended behaviour and just represents the natural application flow. Exception handling in PHP does not have any concept of output buffering and operates in a generic way. You start output buffering but you don't explicitly turn it of or clean the contents and thus, when the script ends (inside your catch block), it will be automatically flushed (displayed). If you don't want any output, make sure your catch block first calls ob_end_clean() before it exits. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Visibility of class constant
-Original Message- From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] Sent: 03 February 2009 05:03 To: php-general@lists.php.net Subject: [PHP] Visibility of class constant I got a weird behaviour of class constant. Suppose I have Index_Controller and Another_Controller classes, both extending Controller class. I define some constants (let's assume I only have one, call it MY_CONST) in Controller class to be used by its descendants. In Index_Controller, I can freely use MY_CONST without parent:: needed. However, this isn't the case with Another_Controller. Without parent:: I got notice Use of undefined constant MY_CONST - assumed 'MY_CONST'. How could this happen and what's the correct behaviour? It's actually nicer to have it without parent::, assuming that constants have protected visibility specifier (which isn't possible AFAIK :-( ). You cannot access a class constant just by the constant name. See http://docs.php.net/manual/en/language.oop5.paamayim-nekudotayim.php. you need to use self::MY_CONST, I guess; your code might make it clearer. e.g. class Controller { const CONSTANT = 'foobr /'; } class Index_Controller extends Controller { public function __construct() { echo CONSTANT; echo 'br/'; // gives warning echo self::CONSTANT; // foo echo parent::CONSTANT;// foo } } class Another_Controller extends Controller { const CONSTANT = 'barbr /'; public function __construct() { echo self::CONSTANT; // bar echo parent::CONSTANT;// foo } } new Index_Controller would give you the warning you described for CONSTANT and return 'foo' for self::CONSTANT and parent::CONSTANT as CONSTANT was inherited. In Another_Controller CONSTANT is overridden so self::CONSTANT would be 'bar' and parent::CONSTANT would be 'foo'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?
Edmund Hertle schreef: 2009/2/3 Daevid Vincent dae...@daevid.com Is there a way to create a new property via PHP 5.2.4? I get a hash back from an authentication server. I'm not guaranteed that someone in another department won't add new key/values to the returned hash/array. I'm trying to work around that part gracefully so that the code doesn't blow up on a customer in such an event. The main try/catch will suppress errors already, but I thought it would be nice to be able to handle this stuff automatically rather than constantly updating a User.class.php file all the time. creating new property this-oraclecustomerid with 1122 but when I try to set the value with the $this-$pkey = $value; It triggers __call() which then triggers __set() which throws my BadProperty exception. How come $this-$pkey = $value isn't creating/setting a property? Or how do I do something like create_property($this, $pkey); so that I can then set it via $this-oraclecustomerid = 1122 or $this-set_oraclecustomerid(1122) ??? ?php function load_from_user_data($user_data) { //now loop through the rest of the user_data array and assign via a set_foo() method foreach ($user_data as $key = $value) { //try { $pkey = strtolower($key); //[dv] this is sort of a hack to automatically create a new property/variable // for 'new' hashes key/values we may not know about. // It's really designed to supress errors and they really should be added to this User.class.php properly. if ( !property_exists($this, $pkey) ) { echo creating new property this-$pkey with $valuebr\n; $this-$pkey = $value; //THIS BLOWS UP ON THE __set() echo this-$pkey = .$this-$pkey; } Hey, well, $this-$pkey is wrong syntax. Try $this-pkey = $value there is nothing wrong with $this-$pkey. the question is what is __set() doing, if it's throwing an exception for undefined properties then obviously it with 'blow up'. I would suggest looking into using an array inside the object to store all user data, you can still use some setter methods for user fields that are known at compile time and for the rest you just stuff the extra/unknown fields into the array, something like: class Test { private $data = array(); function loadUserData($data) { foreach ($data as $key = $val) { if (method_exists($this, 'set_'.$key) $this-{'set_'.$key}($val); else $this-data[ $key ] = $val; } } } -eddy else { $class_variable = 'set_'.$pkey; $this-$class_variable($value); unset($user_data[$key]); } } //catch (Exception $e) { //echo $e-getMessage().\n; } } //should new fields be returned in the $user_data that are not accounted for above... if ($_SESSION['DEVELOPMENT'] count($user_data)) { echo !-- Unaccounted for user_data hashes. Please add these into User.class.php:\n; var_dump($user_data); echo --; } //THESE TWO LINES FATAL ERROR ON THE __get(): echo this-oraclecustomerid = .$this-oraclecustomerid; echo this-get_oraclecustomerid() = .$this-get_oraclecustomerid(); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] calculate the time that day ends
Hi gang, I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Throwing an exception seems to defeat output buffering
I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output.. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? Thank you, Leif Wickland -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Hi gang, I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. -- Thodoris Doesn't every day end at 23:59:59? the next second would be 00:00:00...the beginning of a new day! :) So to put this time into a variable you could do: $end_of_day = mktime(23, 59, 59, date(m), date(d), date(Y); that will give you the value for today (mm/dd/) at 23:59:59.
Re: [PHP] calculate the time that day ends
2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. -- Thodoris
[PHP] Re: calculate the time that day ends
Thodoris wrote: Hi gang, I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. I'm not sure that I understand, but I'm pretty sure that every day ends on 23:59:59. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] calculate the time that day ends
Try: echo date(H:i:s, mktime(23-date(H), 59-date(i), 59-date(s)); -Mensagem original- De: Thodoris [mailto:t...@kinetix.gr] Enviada em: terça-feira, 3 de fevereiro de 2009 14:38 Para: Stuart Cc: php-general@lists.php.net Assunto: Re: [PHP] calculate the time that day ends 2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Throwing an exception seems to defeat output buffering
Wickland, Leif wrote: I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output.. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? Thank you, Leif Wickland Others have told you why, so these will work as you want (depending upon what you want :) You can use ob_end_clean() unless you need the contents of the buffer. I assigned the return of ob_get_contents() to a var because I assume you have the exits() for testing. ? try { ob_start(); echo 'h1You should not see this!/h1'; $buffer = ob_get_clean(); throw new Exception('h2This should be the first output./h2'); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } -- or -- ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); } catch (Exception $ex) { $buffer = ob_get_clean(); exit('h2Exception:/h2' . $ex-getMessage()); } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Thodoris wrote: 2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. STFW http://www.google.com/search?q=calculate+sunset+formula -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] calculate the time that day ends
Try: echo date(H:i:s, mktime(23-date(H), 59-date(i), 59-date(s)); This is I guess how much time we have to reach midnight. But the question is how to calculate the time that sun stops showing its refreshing light. BTW try not to top post -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Shawn McKenzie wrote: Thodoris wrote: 2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. STFW http://www.google.com/search?q=calculate+sunset+formula Wow, also: http://www.google.com/search?q=php+calculate+sunset Yields this gem: http://www.w3schools.com/php/func_date_sunset.asp -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Shawn McKenzie wrote: Shawn McKenzie wrote: Thodoris wrote: 2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. STFW http://www.google.com/search?q=calculate+sunset+formula Wow, also: http://www.google.com/search?q=php+calculate+sunset Yields this gem: http://www.w3schools.com/php/func_date_sunset.asp Whooa. I thought that was actual code for the function, but it appears that it is a PHP5 function! Who would've thunk? http://php.net/date_sunset -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Shawn McKenzie wrote: Thodoris wrote: 2009/2/3 Thodoris t...@kinetix.gr: I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. STFW http://www.google.com/search?q=calculate+sunset+formula Wow, also: http://www.google.com/search?q=php+calculate+sunset Yields this gem: http://www.w3schools.com/php/func_date_sunset.asp Thanks Shawn this could make a good start: http://www.phpclasses.org/browse/package/2642.html -- Thodoris
Re: [PHP] Throwing an exception seems to defeat output buffering
2009/2/3 Wickland, Leif lwickl...@rightnow.com: I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output.. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? It doesn't, but the end of the script performs an implicit flush. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Throwing an exception seems to defeat output buffering
2009/2/3 Shawn McKenzie nos...@mckenzies.net Wickland, Leif wrote: I would expect that if I turn on output buffering, echo something, throw an exception, and catch the exception, nothing will have been actually output.. That doesn't seem to be the case. Throwing an exception seems to defeat output buffering. In the following code, I would not expect to see the h1, but I do. ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); exit( 'Contents: ' . ob_get_clean()); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } I'm exercising that code on PHP 5.2.4 and 5.2.8. Does anybody know why throwing an exception seems to override ob_start(), flushing the buffered output? Thank you, Leif Wickland Others have told you why, so these will work as you want (depending upon what you want :) You can use ob_end_clean() unless you need the contents of the buffer. I assigned the return of ob_get_contents() to a var because I assume you have the exits() for testing. ? try { ob_start(); echo 'h1You should not see this!/h1'; $buffer = ob_get_clean(); throw new Exception('h2This should be the first output./h2'); } catch (Exception $ex) { exit('h2Exception:/h2' . $ex-getMessage()); } -- or -- ? try { ob_start(); echo 'h1You should not see this!/h1'; throw new Exception('h2This should be the first output./h2'); } catch (Exception $ex) { $buffer = ob_get_clean(); exit('h2Exception:/h2' . $ex-getMessage()); } Or you can create a custom exception class, and add the above functionality in the constructor. Either clean the buffer, or save it within the exception of needed. That way you won't have to bother with ob, if you use this often. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Alpar Torok
Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?
On Tue, 2009-02-03 at 12:51 +0100, Jochem Maas wrote: Edmund Hertle schreef: 2009/2/3 Daevid Vincent dae...@daevid.com Is there a way to create a new property via PHP 5.2.4? I get a hash back from an authentication server. I'm not guaranteed that someone in another department won't add new key/values to the returned hash/array. I'm trying to work around that part gracefully so that the code doesn't blow up on a customer in such an event. The main try/catch will suppress errors already, but I thought it would be nice to be able to handle this stuff automatically rather than constantly updating a User.class.php file all the time. creating new property this-oraclecustomerid with 1122 but when I try to set the value with the $this-$pkey = $value; It triggers __call() which then triggers __set() which throws my BadProperty exception. How come $this-$pkey = $value isn't creating/setting a property? Or how do I do something like create_property($this, $pkey); so that I can then set it via $this-oraclecustomerid = 1122 or $this-set_oraclecustomerid(1122) ??? ?php function load_from_user_data($user_data) { //now loop through the rest of the user_data array and assign via a set_foo() method foreach ($user_data as $key = $value) { //try { $pkey = strtolower($key); //[dv] this is sort of a hack to automatically create a new property/variable // for 'new' hashes key/values we may not know about. // It's really designed to supress errors and they really should be added to this User.class.php properly. if ( !property_exists($this, $pkey) ) { echo creating new property this-$pkey with $valuebr\n; $this-$pkey = $value; //THIS BLOWS UP ON THE __set() echo this-$pkey = .$this-$pkey; } the question is what is __set() doing, if it's throwing an exception for undefined properties then obviously it with 'blow up'. But why should __set() even be called if I'm accessing the property directly? This seems stupid. $this-oraclecustomerid = 1122; should NOT be the same as $this-set_oraclecustomerid(1122); The second one I agree should call __set(), but the first one should NOT be triggering __call() or __set() else { $class_variable = 'set_'.$pkey; $this-$class_variable($value); unset($user_data[$key]); } } //catch (Exception $e) { //echo $e-getMessage().\n; } } //should new fields be returned in the $user_data that are not accounted for above... if ($_SESSION['DEVELOPMENT'] count($user_data)) { echo !-- Unaccounted for user_data hashes. Please add these into User.class.php:\n; var_dump($user_data); echo --; } //THESE TWO LINES FATAL ERROR ON THE __get(): echo this-oraclecustomerid = .$this-oraclecustomerid; echo this-get_oraclecustomerid() = .$this-get_oraclecustomerid(); } ?
Re: [PHP] calculate the time that day ends
At 11:36 AM -0500 2/3/09, Dan Shirah wrote: Doesn't every day end at 23:59:59? the next second would be 00:00:00...the beginning of a new day! :) Splitting hairs. December 31, 2008 had two 23:59:59 -- it was a leap second for that year. My grand-kids, being the nerds that they are counted the New Year down like so: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, Happy New Year! Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to send POST vars through a header redirect?
On Tue, Feb 3, 2009 at 2:54 PM, Jim Lucas li...@cmsws.com wrote: TS wrote: I'm trying to send vars via POST somehow. Is this possible? Currently I'm doing header(Location: http://domain/index.php?var=3;); but, want to send POST or some other method that doesn't stick with the session. Thanks, T No, it is not possible. You will need to look into cURL or something else. But it cannot be done via the header() function. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could always create major overhead and stick it in the database. Ha... -- Kyle Terry | www.kyleterry.com Help kick start VOOM (Very Open Object Model) for a library of PHP classes. http://www.voom.me | IRC EFNet #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?
On Tue, Feb 3, 2009 at 4:19 PM, Daevid Vincent dae...@daevid.com wrote: On Wed, 2009-02-04 at 08:58 +1100, Chris wrote: the question is what is __set() doing, if it's throwing an exception for undefined properties then obviously it with 'blow up'. But why should __set() even be called if I'm accessing the property directly? This seems stupid. $this-oraclecustomerid = 1122; should NOT be the same as $this-set_oraclecustomerid(1122); The second one I agree should call __set(), but the first one should NOT be triggering __call() or __set() Yes it should. http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members __set() is run when writing data to inaccessible members. if it's a protected/private variable, it'll call __set. If it's a variable that doesn't exist, it'll call __set. Let me rephrase that. I see now that it is designed that way, but I think the logic is erroneous. While I'm sure this argument/discussion is all for naught now, I believe that a straight assignment of a value to a variable, SHOULD NOT do any behind the scenes magic __set(). It should just do it. Otherwise, what's the point of being able to set a property/variable both ways? One gives no benefit over the other and as illustrated decreases flexibility. It appears it will work if I change my property to public, but I don't want them exposed like that. *sigh* Bottom line is there should be a create_property($name, $value = null, $type = 'protected') function/method that I can call to do what I'm trying to do. I assume unset($this-foo); works. So therefore, I can check for existence of a property, and consequently remove a property, but I cannot create a property. wow, obviously you can create properties at runtime. if you want direct access to property assignment, dont define __set() for that class. if you want to override this assignment, then define __set() for that class, pretty simple.. and property creation / assignment is essentially the same thing, since all properties must store a value. when you 'create' a property in php w/o explicitly giving it a value the default value is NULL. i recommend that if you want to keep __set() defined in this class you mentioned, and not have the melt-down b/c you have some check to see if the property exists, you can just define another method, createOrSet($property, $value), something to that effect, which will ignore the step about verifying the property already exists. -nathan
Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?
the question is what is __set() doing, if it's throwing an exception for undefined properties then obviously it with 'blow up'. But why should __set() even be called if I'm accessing the property directly? This seems stupid. $this-oraclecustomerid = 1122; should NOT be the same as $this-set_oraclecustomerid(1122); The second one I agree should call __set(), but the first one should NOT be triggering __call() or __set() Yes it should. http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members __set() is run when writing data to inaccessible members. if it's a protected/private variable, it'll call __set. If it's a variable that doesn't exist, it'll call __set. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to send POST vars through a header redirect?
TS wrote: I'm trying to send vars via POST somehow. Is this possible? Currently I'm doing header(Location: http://domain/index.php?var=3;); but, want to send POST or some other method that doesn't stick with the session. Thanks, T No, it is not possible. You will need to look into cURL or something else. But it cannot be done via the header() function. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to send POST vars through a header redirect?
On Tue, Feb 3, 2009 at 2:54 PM, Jim Lucas li...@cmsws.com wrote: TS wrote: I'm trying to send vars via POST somehow. Is this possible? Currently I'm doing header(Location: http://domain/index.php?var=3;); but, want to send POST or some other method that doesn't stick with the session. Thanks, T No, it is not possible. You will need to look into cURL or something else. But it cannot be done via the header() function. I second that you need to use curl: $header = array( MIME-Version=1.0, Content-type=text/html; charset=utf-8 ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this-elqPosturl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, $this-curlOptTimeOut); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_PROXY, $this-proxyServer); curl_setopt($ch, CURLOPT_PROXYPORT, $this-proxyPort); curl_setopt($ch, CURLOPT_POSTFIELDS, $inputArray); curl_setopt($ch, CURLOPT_USERAGENT, 'MSIE'); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HEADER, 1); $data = curl_exec($ch); Thanks, V
Re: [PHP] [PROJECT HELP] - JotBug - A Project Management Issue Tracker written 100% with Zend Framework
Hi, I now have a demo site available so you can easily monitor the projects progress. The site is updated daily with the svn checkins. http://www.jotbug.org The source is still hosted at http://jotbug.googlecode.com Regards, - Robert rcastley wrote: Hi, I am looking (begging!) for help/testing/feedback etc etc etc on my JotBug project http://jotbug.googlecode.com So far, I have the following implemented: Wiki - Syntax is Textile - Add - Edit - Preview - Delete - Attachments (upload/view) - Code highlighting using Geshi - Macro Plugins Tracker - Add - List - View Authentication - Dummy Login SCM - SVN browser - SVN viewer - code highlighting using GeSHi Mutiple Project Listing I am working on e-mail notification and user profile/account settings at the moment. Thanks in advance. - Robert -- View this message in context: http://www.nabble.com/-PROJECT-HELPJotBug---A-Project-Management---Issue-Tracker-written-100--with-Zend-Framework-tp21696826p21819830.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?
On Wed, 2009-02-04 at 08:58 +1100, Chris wrote: the question is what is __set() doing, if it's throwing an exception for undefined properties then obviously it with 'blow up'. But why should __set() even be called if I'm accessing the property directly? This seems stupid. $this-oraclecustomerid = 1122; should NOT be the same as $this-set_oraclecustomerid(1122); The second one I agree should call __set(), but the first one should NOT be triggering __call() or __set() Yes it should. http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members __set() is run when writing data to inaccessible members. if it's a protected/private variable, it'll call __set. If it's a variable that doesn't exist, it'll call __set. Let me rephrase that. I see now that it is designed that way, but I think the logic is erroneous. While I'm sure this argument/discussion is all for naught now, I believe that a straight assignment of a value to a variable, SHOULD NOT do any behind the scenes magic __set(). It should just do it. Otherwise, what's the point of being able to set a property/variable both ways? One gives no benefit over the other and as illustrated decreases flexibility. It appears it will work if I change my property to public, but I don't want them exposed like that. *sigh* Bottom line is there should be a create_property($name, $value = null, $type = 'protected') function/method that I can call to do what I'm trying to do. I assume unset($this-foo); works. So therefore, I can check for existence of a property, and consequently remove a property, but I cannot create a property.
Re: [PHP] Re: calculate the time that day ends
Am Dienstag, 3. Februar 2009 schrieb Shawn McKenzie: I'm not sure that I understand, but I'm pretty sure that every day ends on 23:59:59. No, for some people only most days :-) : http://en.wikipedia.org/wiki/Leap_second some days end on 23:59:60 which is not the same as 00:00:00. Ralf -- Miss Wormwood: What state do you live in? Calvin: Denial. Miss Wormwood: I don't suppose I can argue with that... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?
On Tue, 2009-02-03 at 08:30 +0100, Edmund Hertle wrote: 2009/2/3 Daevid Vincent dae...@daevid.com Is there a way to create a new property via PHP 5.2.4? I get a hash back from an authentication server. I'm not guaranteed that someone in another department won't add new key/values to the returned hash/array. I'm trying to work around that part gracefully so that the code doesn't blow up on a customer in such an event. The main try/catch will suppress errors already, but I thought it would be nice to be able to handle this stuff automatically rather than constantly updating a User.class.php file all the time. creating new property this-oraclecustomerid with 1122 but when I try to set the value with the $this-$pkey = $value; It triggers __call() which then triggers __set() which throws my BadProperty exception. How come $this-$pkey = $value isn't creating/setting a property? Or how do I do something like create_property($this, $pkey); so that I can then set it via $this-oraclecustomerid = 1122 or $this-set_oraclecustomerid(1122) ??? ?php function load_from_user_data($user_data) { //now loop through the rest of the user_data array and assign via a set_foo() method foreach ($user_data as $key = $value) { //try { $pkey = strtolower($key); //[dv] this is sort of a hack to automatically create a new property/variable // for 'new' hashes key/values we may not know about. // It's really designed to supress errors and they really should be added to this User.class.php properly. if ( !property_exists($this, $pkey) ) { echo creating new property this-$pkey with $valuebr\n; $this-$pkey = $value; //THIS BLOWS UP ON THE __set() echo this-$pkey = .$this-$pkey; } Hey, well, $this-$pkey is wrong syntax. Try $this-pkey = $value No Eddie, it's one of the beautiful, simple and powerful things about PHP. http://www.php.net/manual/en/language.variables.variable.php As I loop over the hash, i am TRYING to create a new class property of the key and assigning it the value. $pkey is basically the hash's $key in mixed case, forced to lowercase. You can do this for variables and for functions/methods too. This is a 'factory'. I've used it for example for parsing an XML file and operating on the data within various 'blocks' by reading the block name=foo value=bar and then executing $$name($value). Thanks for trying though. ;-) else { $class_variable = 'set_'.$pkey; $this-$class_variable($value); unset($user_data[$key]); } } //catch (Exception $e) { //echo $e-getMessage().\n; } } //should new fields be returned in the $user_data that are not accounted for above... if ($_SESSION['DEVELOPMENT'] count($user_data)) { echo !-- Unaccounted for user_data hashes. Please add these into User.class.php:\n; var_dump($user_data); echo --; } //THESE TWO LINES FATAL ERROR ON THE __get(): echo this-oraclecustomerid = .$this-oraclecustomerid; echo this-get_oraclecustomerid() = .$this-get_oraclecustomerid(); } ?
[PHP] Is it possible to send POST vars through a header redirect?
I'm trying to send vars via POST somehow. Is this possible? Currently I'm doing header(Location: http://domain/index.php?var=3;); but, want to send POST or some other method that doesn't stick with the session. Thanks, T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Visibility of class constant
Got it, thanks. I see that PHP is unlike many other OO language, it's a little stricter in scoping. -- View this message in context: http://www.nabble.com/Visibility-of-class-constant-tp21803985p21823751.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Visibility of class constant
Chris Scott wrote: You cannot access a class constant just by the constant name. See http://docs.php.net/manual/en/language.oop5.paamayim-nekudotayim.php. Holy crap! Why can't it just be :: or double colon! -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
Shawn McKenzie a écrit : STFW That's not so fair. If Thodoris ask about day end, it is obvious he's wrong with the word. Wrong because he isn't mastering english. So, without the good word (sunset), he can't find. So please don't bash us when we appear silly ! -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org Seeking for a position http://lupusmic.org/pro/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php