Re: [PHP] Static Class Member References
On 12 July 2010 22:54, Daniel Kolbo wrote: > Richard Quadling wrote: >> On 11 July 2010 23:19, Daniel Kolbo wrote: >>> Hello PHPers, >>> >>> I'm having some trouble understanding some PHP behaviour. The following >>> example script exhibits the behaviour which I cannot understand. >>> [code] >>> >> >>> class A >>> { >>> public static $a = 3; >>> >>> function __construct() >>> { >>> //self::$a = $this; //[i] >>> self::$a =& $this; //[ii] >>> } >>> } >>> >>> class B extends A >>> { >>> function __construct() >>> { >>> parent::__construct(); >>> } >>> } >>> >>> class C { >>> var $c; >>> >>> function __construct() >>> { >>> $this->c =& A::$a; >>> } >>> >>> } >>> >>> >>> $c = new C; >>> $b = new B; >>> $cee = new C; >>> >>> var_dump($c->c); // [i] prints object(B), but [ii] prints int 3 >>> var_dump($cee->c); // [i] prints object(B), and [ii] prints object(B) >>> >>> ?> >>> [/code] >>> >>> Why does $c->c print 'int 3' ? >>> >>> I'm nervous to use "self::$a = $this;" because I don't want to be >>> copying the whole object. However, isn't $this just a reference to the >>> object, so "self::$a = $this;" is just copying the reference and not the >>> actual object, right? >>> >>> Thanks in advance >> >> >> What do you think the value should be? >> >> A static property is bound to the class and not to an instance of the class. >> >> So, &A::$a is a reference to the static value. If you alter the value, >> it will be altered for a subclasses of A and for any other reference >> to it. >> > > I think > var_dump($c->c); would print object(B), but it's printing int 3. > > The reference is *not* being updated. I think this is a bug. What do > you think? > > Thanks > ` > > What version of PHP are you using? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static Class Member References
On 13 July 2010 09:46, Richard Quadling wrote: > On 12 July 2010 22:54, Daniel Kolbo wrote: >> Richard Quadling wrote: >>> On 11 July 2010 23:19, Daniel Kolbo wrote: Hello PHPers, I'm having some trouble understanding some PHP behaviour. The following example script exhibits the behaviour which I cannot understand. [code] >>> class A { public static $a = 3; function __construct() { //self::$a = $this; //[i] self::$a =& $this; //[ii] } } class B extends A { function __construct() { parent::__construct(); } } class C { var $c; function __construct() { $this->c =& A::$a; } } $c = new C; $b = new B; $cee = new C; var_dump($c->c); // [i] prints object(B), but [ii] prints int 3 var_dump($cee->c); // [i] prints object(B), and [ii] prints object(B) ?> [/code] Why does $c->c print 'int 3' ? I'm nervous to use "self::$a = $this;" because I don't want to be copying the whole object. However, isn't $this just a reference to the object, so "self::$a = $this;" is just copying the reference and not the actual object, right? Thanks in advance >>> >>> >>> What do you think the value should be? >>> >>> A static property is bound to the class and not to an instance of the class. >>> >>> So, &A::$a is a reference to the static value. If you alter the value, >>> it will be altered for a subclasses of A and for any other reference >>> to it. >>> >> >> I think >> var_dump($c->c); would print object(B), but it's printing int 3. >> >> The reference is *not* being updated. I think this is a bug. What do >> you think? >> >> Thanks Aha! $c = new C; At this stage $c->c will be a reference to the static A::$a = 3. $b = new B; Now, as B's constructor calls A's constructor which replaces the static A::$a with a reference to the instance $b, the static A::$a should now be $b $cee = new C; At this stage $cee->c will be a reference to the static A::$a = $b. But, when var_dump()'d, $c->c !== $cee->c, and I think they should as both have been assigned to a reference of a static. It would seem to be a bug. I get the same output for V5.0.0 to V5.3.3RC2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with sql statement
On 12 July 2010 18:34, Tommy Pham wrote: > SELECT srs.Name FROM SMS_R_System srs WHERE srs.SystemOUName IN > ("example.com/COMPUTERS/MAIN CAMPUS/ABC", "example.com/COMPUTERS/MAIN > CAMPUS/XYZ") > As this is a single table query, there is no need for the table alias. SELECT Name FROM SMS_R_System WHERE LEFT(SystemOUName, 34) = 'example.com/COMPUTERS/MAIN CAMPUS/' AND RIGHT(SystemOUName, 3) IN ('ABC', 'XYZ') But this will probably take a measurable amount of time longer to execute - 2 comparisons and 2 string processes. Maybe not for a single run, but after several hundred. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate if the field of a form is empty
It works fine for me, foreach ( $_FILES['archivo']['name'] as $file ) { //echo $file; } if($file == ""){ echo "empty"; }else{ //continue... } Thanks a lot Jim! Te0
[PHP] Help with template file and email
Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! This is my code-
Re: [PHP] Help with template file and email
On 13 July 2010 14:56, Joey Hendricks wrote: > Hello, > I have been working on a birtday invite program. The form takes 10 names and > 10 email addresses. I think the problem is the $to variable in my function. I > get this warning-Warning: mail() [function.mail]: SMTP server response: 550 > 5.5.0 domain name required in. > Could someone help me with this my email is j.hendrick...@comcast.net Thank > you so very much! and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Posting values of dynamically generated text fields at a time
Hi is anybody there to help me out on this? > > Hi all, > I am new to PHP and JS. > > I am adding new text fields using javascript and I have to save the values > of these fields in database in single row. So, how should I post these > values? So that I can save them in the db. > > Additional Info: There are 6 text fields in the row. I have to post the > information of all the fields collectively. > > So, please suggest me a way. > -- > Thanks and Regards, > Amit > > -- Thanks and Regards, Amit eArth Solutions Pvt. Ltd
[PHP] XML parser
Hello. I have html: Header Paragraph 1 Paragraph n Header Paragraph 1 Paragraph n need to parse it like this array: array( [0] => array( 'h3' => 'header' , 'p' => array( [0] => 'Paragraph 1' , [n-1] => 'Paragraph N' ) [1] => array( ['div'] => array ( 'h3' => 'header' , 'p' => array( [0] => 'Paragraph 1' , [n-1] => 'Paragraph N' ) ) ; maybe simple other. Which pear class i can use for this task ?
Re: [PHP] Posting values of dynamically generated text fields at a time
On 13 July 2010 15:06, Amit Bobade wrote: > Hi is anybody there to help me out on this? > >> >> Hi all, >> I am new to PHP and JS. >> >> I am adding new text fields using javascript and I have to save the values >> of these fields in database in single row. So, how should I post these >> values? So that I can save them in the db. >> >> Additional Info: There are 6 text fields in the row. I have to post the >> information of all the fields collectively. >> >> So, please suggest me a way. >> -- >> Thanks and Regards, >> Amit >> >> > > > -- > Thanks and Regards, > Amit > eArth Solutions Pvt. Ltd > If the tags are added to the , or to an element within the , then when you submit the form, the newly created elements will also be submitted. Whilst you can read the form property of an input element (or select/textarea), this property is read-only. Give them a name. If they are a collection of items, then give them a name like name="something[]" and you will get a $_POST['something'] array (or $_GET if you are using method="get"). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP question
On 13 July 2010 15:46, Joey Hendricks wrote: > Hi Mr. Quadling, > Thank you for the reply. I still don't understand how to get all the emails > into the function. Before I put in the function I had something like this- > for($i=0; $i<=9; $i++) > { > if(!empty($_GET[email.$i])) > { > mail($_GET[email.$i], $email_subject, $email_message, "From: ".$from); > } > } > But then I made this function- > function mail_message($data_array, $template_file, $deadline_str) > { > $email_message = file_get_contents($template_file); > $email_message = str_replace("#DEADLINE#", $deadline_str, $email_message); > $email_message = str_replace("#DATE#", date("F d, Y h:i a"), > $email_message); > $email_message = str_replace("#NAME#", $data_array['name'], $email_message); > //This to variable is where I get the error > $to=$mymail; > $from='j.hendrick...@comcast.net'; > $email_subject='Bubs Birthday'; > mail($to, $email_subject, $email_message, "From: ".$from); > } > And this is where I call the function- > if(!empty($_GET[email.$i])) > { > mail_message($_GET[email.$i], "email_template.txt", $deadline_str); > } > Thank you very very much for your help. > Joey. Try ... $to = ''; foreach(range(1,9) as $i) { $to .= (!!$to ? ',', : '') . $_GET["email{$i}"]; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with template file and email
Let me get this right... $mymail // If you put an email adress it works, right. You are calling variable $mymail... But, what does contain that var? You are calling $mymail, there has to be a database, or something of those 10 mails you said. -If i'm getting you the point right- If not, my mistake. Or you might use something like this: http://docs.php.net/manual/en/function.mail.php -as Richard said.- > From: rquadl...@gmail.com > Date: Tue, 13 Jul 2010 15:02:14 +0100 > To: j.hendrick...@comcast.net > CC: php-general@lists.php.net > Subject: Re: [PHP] Help with template file and email > > On 13 July 2010 14:56, Joey Hendricks wrote: > > Hello, > > I have been working on a birtday invite program. The form takes 10 names > > and 10 email addresses. I think the problem is the $to variable in my > > function. I get this warning-Warning: mail() [function.mail]: SMTP server > > response: 550 5.5.0 domain name required in. > > Could someone help me with this my email is j.hendrick...@comcast.net Thank > > you so very much! > > mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); > ?> > > and I get the following entry in my PHP's mail.log ... > > mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: > > Pretty simple stuff. > > http://docs.php.net/manual/en/function.mail.php > > Regards, > > Richard. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
Re: [PHP] XML parser
On Tue, Jul 13, 2010 at 10:14 AM, ppps...@gmail.com wrote: > Hello. I have html: > Header > Paragraph 1 > > Paragraph n > > > Header > Paragraph 1 > > Paragraph n > > > need to parse it like this array: > array( > [0] => array( > 'h3' => 'header' , > 'p' => array( > [0] => 'Paragraph 1' , > [n-1] => 'Paragraph N' > ) > [1] => array( > ['div'] => array ( > 'h3' => 'header' , > 'p' => array( > [0] => 'Paragraph 1' , > [n-1] => 'Paragraph N' > ) > ) ; > > maybe simple other. Which pear class i can use for this task ? > > > Why PEAR? That looks almost exactly like SimpleXML. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running out of memory processing result set on Linux, but not on Solaris
I have an app that runs just fine on an older Solaris apache server (Apache/2.0.53 PHP/5.0.4), but when I run the same app on a newer Linux server (Apache/2.2.3-11 PHP/5.2.8) against the same database on the same mysql server, it fails with "Allowed memory size exhausted". This occurs on a: $result = mysql_query($query, $db) statement. Both servers are running the identical query, which returns a result set under 0.5M. The Solaris server is configured with memory_limit = 8M in php.ini, and the Linux one with 32M, so clearly something other then what I'm seeing is going on. Anyone know what could be causing this? Any php or apache build or config options that I could look at? TIA! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running out of memory processing result set on Linux, but not on Solaris
On Tue, 2010-07-13 at 11:06 -0600, Larry Martell wrote: > I have an app that runs just fine on an older Solaris apache server > (Apache/2.0.53 PHP/5.0.4), but when I run the same app on a newer > Linux server (Apache/2.2.3-11 PHP/5.2.8) against the same database on > the same mysql server, it fails with "Allowed memory size exhausted". > This occurs on a: > > $result = mysql_query($query, $db) > > statement. Both servers are running the identical query, which returns > a result set under 0.5M. The Solaris server is configured with > memory_limit = 8M in php.ini, and the Linux one with 32M, so clearly > something other then what I'm seeing is going on. Anyone know what > could be causing this? Any php or apache build or config options that > I could look at? > > TIA! > Is there any other place which your code is changing the memory_limit parameter? I would assume this is unlikely, but sometimes even the unlikely happens more than than it should! Can you maybe strip the code down to a test case which causes the error? Lastly, I do notice that you've got two different versions of PHP & Apache installed on each OS, which could be the reason for the failure. Maybe set up a VM or two to test things out. Have one VM with Solaris and Apache/2.2.3-11 & PHP/5.2.8, and another VM with Apache/2.0.53 & PHP/5.0.4 and see what happens. It could be that it's either Apache or PHP or both causing the problems on your Linux system. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] calendar libs
Hi! i'm looking for a good calendar libs, want ask, if anyone knows a good library. thx! Ricardo
Re: [PHP] calendar libs
On Tue, Jul 13, 2010 at 2:04 PM, Ricardo Martinez wrote: > Hi! > > i'm looking for a good calendar libs, want ask, if anyone knows a good > library. > > > thx! > > Ricardo > This may hel, it's just a simple search for 'php calendar' : http://www.php-calendar.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calendar libs
On Tue, Jul 13, 2010 at 2:10 PM, David Hutto wrote: > On Tue, Jul 13, 2010 at 2:04 PM, Ricardo Martinez > wrote: >> Hi! >> >> i'm looking for a good calendar libs, want ask, if anyone knows a good >> library. >> >> >> thx! >> >> Ricardo >> > > This may hel, it's just a simple search for 'php calendar' : > > http://www.php-calendar.com/ > This might help better as a reference: http://www.w3schools.com/php/php_ref_calendar.asp Not to say there isn't a builtin function, or. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calendar libs
On Tue, Jul 13, 2010 at 2:14 PM, David Hutto wrote: > On Tue, Jul 13, 2010 at 2:10 PM, David Hutto wrote: >> On Tue, Jul 13, 2010 at 2:04 PM, Ricardo Martinez >> wrote: >>> Hi! >>> >>> i'm looking for a good calendar libs, want ask, if anyone knows a good >>> library. >>> >>> >>> thx! >>> >>> Ricardo >>> >> >> This may hel, it's just a simple search for 'php calendar' : >> >> http://www.php-calendar.com/ >> > This might help better as a reference: > > http://www.w3schools.com/php/php_ref_calendar.asp > Not to say there isn't a builtin function, or. > minus the : Not to say there isn't a builtin function, or. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] adduser & php
On Sat, Jul 10, 2010 at 2:39 PM, Matt M. wrote: > The only thing is, when I execute this command from a shell, it works. > Obviously I'm replacing $username and $password with something valid when > doing this manually. > > It's like the script clears the $username variable just before it executes > the command, or because the variable is inside quotes, it is not getting > through. > likely the user the webserver is running as does not have sudo privileges; youll have to properly configure sudo so that the webserver user only has access to run the useradd and w/e other superuser required commands you intend to run from it. -nathan
Re: [PHP] adduser & php
On Tue, 2010-07-13 at 12:56 -0600, Nathan Nobbe wrote: > On Sat, Jul 10, 2010 at 2:39 PM, Matt M. wrote: > > > The only thing is, when I execute this command from a shell, it works. > > Obviously I'm replacing $username and $password with something valid when > > doing this manually. > > > > It's like the script clears the $username variable just before it executes > > the command, or because the variable is inside quotes, it is not getting > > through. > > > > likely the user the webserver is running as does not have sudo privileges; > youll have to properly configure sudo so that the webserver user only has > access to run the useradd and w/e other superuser required commands you > intend to run from it. > > -nathan Not to mention that you have to santise the input anyway to ensure that you're not changing the details for an already existing user, especially a system user. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] running out of memory processing result set on Linux, but not on Solaris
On Tue, Jul 13, 2010 at 11:11 AM, Ashley Sheridan wrote: > > On Tue, 2010-07-13 at 11:06 -0600, Larry Martell wrote: > > I have an app that runs just fine on an older Solaris apache server > (Apache/2.0.53 PHP/5.0.4), but when I run the same app on a newer > Linux server (Apache/2.2.3-11 PHP/5.2.8) against the same database on > the same mysql server, it fails with "Allowed memory size exhausted". > This occurs on a: > > $result = mysql_query($query, $db) > > statement. Both servers are running the identical query, which returns > a result set under 0.5M. The Solaris server is configured with > memory_limit = 8M in php.ini, and the Linux one with 32M, so clearly > something other then what I'm seeing is going on. Anyone know what > could be causing this? Any php or apache build or config options that > I could look at? > > TIA! > > > Is there any other place which your code is changing the memory_limit > parameter? I would assume this is unlikely, but sometimes even the unlikely > happens more than than it should! The error message actually says "Allowed memory size of 3355432 bytes exhausted" so I know it's using the 32M that it's set to php.ini. But as I wrote above, on the Solaris server where it works, the memory_limit is set to 8M. > Can you maybe strip the code down to a test case which causes the error? I've already done that - all it does it run a query and display the results. > Lastly, I do notice that you've got two different versions of PHP & Apache > installed on each OS, which could be the reason for the failure. Well, yes, that's what I said. And they may been built with different config options. But what options could cause a difference like this? > Maybe set up a VM or two to test things out. Have one VM with Solaris and > Apache/2.2.3-11 & PHP/5.2.8, and another VM with Apache/2.0.53 & PHP/5.0.4 > and see what happens. It could be that it's either Apache or PHP or both > causing the problems on your Linux system. I don't have control of that. This is at a client site - they want to get rid of their existing older Solaris apache server and move to a newer Linux one. The servers are already set up they way they are. I asked the admis for info on the build - they have it for the newer Linux one, but not for the older Solaris one. They did give me another machine to test on - that one is Linux, Apache 2.2.3, PHP 5.2.6 - that also gets the out of memory error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running out of memory processing result set on Linux, but not on Solaris
On Tue, 2010-07-13 at 14:22 -0600, Larry Martell wrote: > On Tue, Jul 13, 2010 at 11:11 AM, Ashley Sheridan > wrote: > > > > On Tue, 2010-07-13 at 11:06 -0600, Larry Martell wrote: > > > > I have an app that runs just fine on an older Solaris apache server > > (Apache/2.0.53 PHP/5.0.4), but when I run the same app on a newer > > Linux server (Apache/2.2.3-11 PHP/5.2.8) against the same database on > > the same mysql server, it fails with "Allowed memory size exhausted". > > This occurs on a: > > > > $result = mysql_query($query, $db) > > > > statement. Both servers are running the identical query, which returns > > a result set under 0.5M. The Solaris server is configured with > > memory_limit = 8M in php.ini, and the Linux one with 32M, so clearly > > something other then what I'm seeing is going on. Anyone know what > > could be causing this? Any php or apache build or config options that > > I could look at? > > > > TIA! > > > > > > Is there any other place which your code is changing the memory_limit > > parameter? I would assume this is unlikely, but sometimes even the unlikely > > happens more than than it should! > > The error message actually says "Allowed memory size of 3355432 bytes > exhausted" so I know it's using the 32M that it's set to php.ini. But > as I wrote above, on the Solaris server where it works, the > memory_limit is set to 8M. > > > Can you maybe strip the code down to a test case which causes the error? > > I've already done that - all it does it run a query and display the results. > > > Lastly, I do notice that you've got two different versions of PHP & Apache > > installed on each OS, which could be the reason for the failure. > > Well, yes, that's what I said. And they may been built with different > config options. But what options could cause a difference like this? > > > Maybe set up a VM or two to test things out. Have one VM with Solaris and > > Apache/2.2.3-11 & PHP/5.2.8, and another VM with Apache/2.0.53 & PHP/5.0.4 > > and see what happens. It could be that it's either Apache or PHP or both > > causing the problems on your Linux system. > > I don't have control of that. This is at a client site - they want to > get rid of their existing older Solaris apache server and move to a > newer Linux one. The servers are already set up they way they are. I > asked the admis for info on the build - they have it for the newer > Linux one, but not for the older Solaris one. They did give me another > machine to test on - that one is Linux, Apache 2.2.3, PHP 5.2.6 - that > also gets the out of memory error. > That's why I suggested a VM, as you can have as many of these set up as you need on your own computer to test things. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] running out of memory processing result set on Linux, but not on Solaris
On Tue, Jul 13, 2010 at 11:06 AM, Larry Martell wrote: > I have an app that runs just fine on an older Solaris apache server > (Apache/2.0.53 PHP/5.0.4), but when I run the same app on a newer > Linux server (Apache/2.2.3-11 PHP/5.2.8) against the same database on > the same mysql server, it fails with "Allowed memory size exhausted". > This occurs on a: > > $result = mysql_query($query, $db) > > statement. Both servers are running the identical query, which returns > a result set under 0.5M. The Solaris server is configured with > memory_limit = 8M in php.ini, and the Linux one with 32M, so clearly > something other then what I'm seeing is going on. Anyone know what > could be causing this? Any php or apache build or config options that > I could look at? > are you sure the app doesnt have some other data loaded into memory before running the query on the linux box? you can use memory_get_usage() right before executing the query on the linux box to determine if thats the case. for example suppose the query takes .5M of memory, when you run it on the solaris box only 4M of memory is currently in use and when you run it on the linux box 31.7M of memory is in use. another easy way to make the determination is to do as ashley suggested and write a script which does nothing other than execute the query. -nathan
Re: [PHP] Static Class Member References
Richard Quadling wrote: > On 12 July 2010 22:54, Daniel Kolbo wrote: >> Richard Quadling wrote: >>> On 11 July 2010 23:19, Daniel Kolbo wrote: Hello PHPers, I'm having some trouble understanding some PHP behaviour. The following example script exhibits the behaviour which I cannot understand. [code] >>> class A { public static $a = 3; function __construct() { //self::$a = $this; //[i] self::$a =& $this; //[ii] } } class B extends A { function __construct() { parent::__construct(); } } class C { var $c; function __construct() { $this->c =& A::$a; } } $c = new C; $b = new B; $cee = new C; var_dump($c->c); // [i] prints object(B), but [ii] prints int 3 var_dump($cee->c); // [i] prints object(B), and [ii] prints object(B) ?> [/code] Why does $c->c print 'int 3' ? I'm nervous to use "self::$a = $this;" because I don't want to be copying the whole object. However, isn't $this just a reference to the object, so "self::$a = $this;" is just copying the reference and not the actual object, right? Thanks in advance >>> >>> What do you think the value should be? >>> >>> A static property is bound to the class and not to an instance of the class. >>> >>> So, &A::$a is a reference to the static value. If you alter the value, >>> it will be altered for a subclasses of A and for any other reference >>> to it. >>> >> I think >> var_dump($c->c); would print object(B), but it's printing int 3. >> >> The reference is *not* being updated. I think this is a bug. What do >> you think? >> >> Thanks >> ` >> >> > > What version of PHP are you using? > I'm using: PHP Version 5.2.13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static Class Member References
Richard Quadling wrote: > On 13 July 2010 09:46, Richard Quadling wrote: >> On 12 July 2010 22:54, Daniel Kolbo wrote: >>> Richard Quadling wrote: On 11 July 2010 23:19, Daniel Kolbo wrote: > Hello PHPers, > > I'm having some trouble understanding some PHP behaviour. The following > example script exhibits the behaviour which I cannot understand. > [code] > > class A > { >public static $a = 3; > >function __construct() >{ >//self::$a = $this; //[i] >self::$a =& $this; //[ii] >} > } > > class B extends A > { >function __construct() >{ >parent::__construct(); >} > } > > class C { >var $c; > >function __construct() >{ >$this->c =& A::$a; >} > > } > > > $c = new C; > $b = new B; > $cee = new C; > > var_dump($c->c); // [i] prints object(B), but [ii] prints int 3 > var_dump($cee->c); // [i] prints object(B), and [ii] prints object(B) > > ?> > [/code] > > Why does $c->c print 'int 3' ? > > I'm nervous to use "self::$a = $this;" because I don't want to be > copying the whole object. However, isn't $this just a reference to the > object, so "self::$a = $this;" is just copying the reference and not the > actual object, right? > > Thanks in advance What do you think the value should be? A static property is bound to the class and not to an instance of the class. So, &A::$a is a reference to the static value. If you alter the value, it will be altered for a subclasses of A and for any other reference to it. >>> I think >>> var_dump($c->c); would print object(B), but it's printing int 3. >>> >>> The reference is *not* being updated. I think this is a bug. What do >>> you think? >>> >>> Thanks > > Aha! > > $c = new C; > > At this stage $c->c will be a reference to the static A::$a = 3. > > $b = new B; > > Now, as B's constructor calls A's constructor which replaces the > static A::$a with a reference to the instance $b, the static A::$a > should now be $b > > $cee = new C; > > At this stage $cee->c will be a reference to the static A::$a = $b. > > But, when var_dump()'d, $c->c !== $cee->c, and I think they should as > both have been assigned to a reference of a static. > > It would seem to be a bug. > > I get the same output for V5.0.0 to V5.3.3RC2 > Thanks for confirming. I reported the bug. I shortened up the test script quite a bit. Please see: Bug #52332 http://bugs.php.net/bug.php?id=52332 ` -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Posting values of dynamically generated text fields at a time
> Hi is anybody there to help me out on this? > >> >> Hi all, >> I am new to PHP and JS. >> >> I am adding new text fields using javascript and I have to save the >> values >> of these fields in database in single row. So, how should I post these >> values? So that I can save them in the db. >> >> Additional Info: There are 6 text fields in the row. I have to post the >> information of all the fields collectively. >> >> So, please suggest me a way. >> -- >> Thanks and Regards, >> Amit >> >> > > > -- > Thanks and Regards, > Amit > eArth Solutions Pvt. Ltd > Hi, this would help you, http://www.w3schools.com/PHP/php_mysql_insert.asp Thanks, Saravana === ***Disclaimer*** This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by Hurix Systems. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. Hurix Systems does not accept liability for damage caused by any of the foregoing. HURIX SYSTEMS MAY MONITOR ALL INCOMING AND OUTGOING MAILS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php