php-general Digest 31 Mar 2006 16:48:25 -0000 Issue 4045
-Greene wrote: The default Apache error handler is not called when PHP sends a 404 header. The code that does Apache error handling happens *before* PHP gets in the loop, and checks to see if the script being referenced exists, which it indeed does, whether it sends a 404 header or not. Tested on Apache 2.2 with PHP 5.1. If you really want to get the default Apache error handler to appear then either readfile() it or redirect to it. Jasper Anthony Ettinger wrote: well, you typically would redirect 404 to something like foo.com/404.html Otherwise, it's whatever your server (apache/IIS) has as the default 404 handler... Default is something like this: Not Found The requested URL /asdf was not found on this server. Apache Server at foo.org Port 80 On 3/30/06, Jasper Bryant-Greene [EMAIL PROTECTED] wrote: In other words, if you want Firefox/Opera/etc to display something, you have to output something. Strange, that. :P Jasper Anthony Ettinger wrote: Then it's workingFireFox, et. al. show you the server 404, IE on the otherhand has it's own 404 error page (for those newbies who don't know what a 404 is). You can disable it under IE options. On 3/30/06, Bronislav Klucka [EMAIL PROTECTED] wrote: Yes, I do... B. Anthony Ettinger wrote: Are you seeing the IE-specific 404 page? The one that looks like this: http://redvip.homelinux.net/varios/404-ie.jpg On 3/30/06, Bronislav Klucka [EMAIL PROTECTED] wrote: Hi, I'm using following construction to send http status code -- header('HTTP/1.1 404 Not Found'); header(Status: 404 Not Found); exit; -- MSIE displays Page not found, but FireFox and Opera don't display anything. Just blank page with no text... full headers sent by this script (and server itself) are: -- Date: Thu, 30 Mar 2006 18:02:49 GMT Server: Apache/2.0.55 (Debian) PHP/4.4.0-4 mod_ssl/2.0.55 OpenSSL/0.9.8a X-Powered-By: PHP/5.1.2 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 404 Not Found -- can anyone tell me, why those two browsers are not affected? Brona -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- I hope I can explain my problem/questions clearly. Thanks in advance: Scenario: I'm working on a Log class that my app will use to write debug/error/etc messages to a file. I've created it so that as the application logs messages, these messages are queued within a property of the Log class, and only written to the file when the Log object is being destroyed. I wanted to place all of the file writing to within __destruct() to avoid holding a connection to the log file throughout the life of the app's state. Problem: Everything works fine, UNLESS I move the fopen('log-file-name') call to within the __destruct() method. If I open a handle to the log file within the __construct() method, or any other class method, it works fine. But I receive a permissions error if it's called within __destruct(). Error reads: Warning: fopen(20060331.txt) [function.fopen]: failed to open stream: Permission denied in ... Caveat: I have found that if I explicitly destroy an instance of Log with unset(), then fopen() will work even when it is within the __destruct() method. However I don't like that solution...and besides, I'm planning on creating an instance of the Log class from within the __construct() of my Controller class, and trying to explicitly destroy Log with an implicit __destruct() of my Controller doesn't work either. :P Question(s): 1. Could anyone explain a bit more as to why fopen() won't work within an implicit call to __destruct()? What permissions has my app lost at this point? 2. Am I at least correct in my intention to limit the duration that the handle to the log file is open? 3. Is there workaround to this little conundrum that anyone can think of? Code: Here's a simplified version of the code (it's complete, feel free to copy-and-paste-and-play). I've commented the fopen code block in question. [code] // Create an instance of Log $log = new Log(); // Attempt to log a message Log::debug(Here
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jasper Bryant-Greene wrote: Jochem Maas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: I think its a misunderstanding on the one side and a limitation on the other, you can't use overloading directly on items of an overloaded array e.g: echo $tc-arr['a'] this is triggers a call to __get() with the $key parameter set to something like (I'm guessing) arr['a'] No, I'm pretty sure (too lazy and tired right now to test...) that if you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this-var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t-arr = array(); $t-arr[a] = 1; echo OUTPUT: \n; var_dump($t-arr); var_dump($t-arr[a]); var_dump($t); ' That's weird, because I did get around to testing it before I saw your mail, and in my test it works as *I* expect (PHP 5.1.2)... a couple of things: I tested on 5.0.4 yesterday (should have mentioned that) - just tried on 5.1.1 and the behaviour there _seems_ to agree with your premise ... but not completely; the outcome is expected but the code doesn't do what I believe it should be doing with regard to guarding against arbitrary crap into an object via __set() - I assume people use __set() to protect variables, in the same way as 'normal' setters are often used. I modified you test code a little - notice how __set() is only called once (the second 'set' is actually a 'get'!): ?php class T { private $array = array(); public function __get( $key ) { echo Getting $key\n; return $this-array[$key]; } public function __set( $key, $value ) { echo Setting $key\n; $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray[test] = testing!; var_dump( $t ); ? OUTPUT: Setting insideArray Getting insideArray object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } I personally feel that the fact that $t-array['insideArray']['test'] is being set (why does __set() seem to return a reference) is unwanted ... it circumvents any variable checking logic I might have in __set() how do like them apples? ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP status code
No, I'm creating remote service and it's returning codes according to passed parameters. I only wanted to test it using browsers... I do not care about the output actually, but the status code B. It seems to me, that this is more html-related. Maybe the tags in the html-document screws it up regarding to the use of html. IE is more insensitive regarding correct typing of html-tags. header('HTTP/1.1 404 Not Found'); header(Status: 404 Not Found); Why do you have ' on the first line and on the second? /Gustav Wiberg Jasper Bryant-Greene wrote: The default Apache error handler is not called when PHP sends a 404 header. The code that does Apache error handling happens *before* PHP gets in the loop, and checks to see if the script being referenced exists, which it indeed does, whether it sends a 404 header or not. Tested on Apache 2.2 with PHP 5.1. If you really want to get the default Apache error handler to appear then either readfile() it or redirect to it. Jasper Anthony Ettinger wrote: well, you typically would redirect 404 to something like foo.com/404.html Otherwise, it's whatever your server (apache/IIS) has as the default 404 handler... Default is something like this: Not Found The requested URL /asdf was not found on this server. Apache Server at foo.org Port 80 On 3/30/06, Jasper Bryant-Greene [EMAIL PROTECTED] wrote: In other words, if you want Firefox/Opera/etc to display something, you have to output something. Strange, that. :P Jasper Anthony Ettinger wrote: Then it's workingFireFox, et. al. show you the server 404, IE on the otherhand has it's own 404 error page (for those newbies who don't know what a 404 is). You can disable it under IE options. On 3/30/06, Bronislav Klucka [EMAIL PROTECTED] wrote: Yes, I do... B. Anthony Ettinger wrote: Are you seeing the IE-specific 404 page? The one that looks like this: http://redvip.homelinux.net/varios/404-ie.jpg On 3/30/06, Bronislav Klucka [EMAIL PROTECTED] wrote: Hi, I'm using following construction to send http status code -- header('HTTP/1.1 404 Not Found'); header(Status: 404 Not Found); exit; -- MSIE displays Page not found, but FireFox and Opera don't display anything. Just blank page with no text... full headers sent by this script (and server itself) are: -- Date: Thu, 30 Mar 2006 18:02:49 GMT Server: Apache/2.0.55 (Debian) PHP/4.4.0-4 mod_ssl/2.0.55 OpenSSL/0.9.8a X-Powered-By: PHP/5.1.2 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 404 Not Found -- can anyone tell me, why those two browsers are not affected? Brona -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Failing to write to a file when a class is being implicitly destroyed
I hope I can explain my problem/questions clearly. Thanks in advance: Scenario: I'm working on a Log class that my app will use to write debug/error/etc messages to a file. I've created it so that as the application logs messages, these messages are queued within a property of the Log class, and only written to the file when the Log object is being destroyed. I wanted to place all of the file writing to within __destruct() to avoid holding a connection to the log file throughout the life of the app's state. Problem: Everything works fine, UNLESS I move the fopen('log-file-name') call to within the __destruct() method. If I open a handle to the log file within the __construct() method, or any other class method, it works fine. But I receive a permissions error if it's called within __destruct(). Error reads: Warning: fopen(20060331.txt) [function.fopen]: failed to open stream: Permission denied in ... Caveat: I have found that if I explicitly destroy an instance of Log with unset(), then fopen() will work even when it is within the __destruct() method. However I don't like that solution...and besides, I'm planning on creating an instance of the Log class from within the __construct() of my Controller class, and trying to explicitly destroy Log with an implicit __destruct() of my Controller doesn't work either. :P Question(s): 1. Could anyone explain a bit more as to why fopen() won't work within an implicit call to __destruct()? What permissions has my app lost at this point? 2. Am I at least correct in my intention to limit the duration that the handle to the log file is open? 3. Is there workaround to this little conundrum that anyone can think of? Code: Here's a simplified version of the code (it's complete, feel free to copy-and-paste-and-play). I've commented the fopen code block in question. [code] // Create an instance of Log $log = new Log(); // Attempt to log a message Log::debug(Here is a debug message.); class Log { protected static $handle; protected static $location; protected static $message; public function __construct() { self::$location = date(Ymd)..txt; /* Begin fopen() */ /* When placed here, it works */ if (!self::$handle = fopen(self::$location,a)) { echo Error. Please check permissions.; die; } /* End fopen() */ } public static function debug($message) { $timestamp = date(Y-m-d H:i:s T); self::$message .= $timestamp.\tdebug\t.$message.\n; } public function __destruct() { if(self::$message) { /* Begin fopen() */ /* If it's here, it won't work! if (!self::$handle = fopen(self::$location,a)) { echo There was an error attempting to open the log file. Please check permissions.; die; } /* End fopen() */ if (fwrite(self::$handle, self::$message) === FALSE) { echo Cannot write to file ({$this-location}); exit; } @fclose(self::$handle); } } } [/code] -John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Failing to write to a file when a class is being implicitly destroyed
basically when php shutsdown at some stage stuff like file manipulation, db access will have been torn down - the implicit object destruction (and therefore the call to __destruct() happens to late in the shutdown process to be of any use ... there is a big chicken and egg problem there (search the archives of the php-internal mailing list should reveal lots of discussion surround this topic) further comments below ... John Wells wrote: I hope I can explain my problem/questions clearly. Thanks in advance: Scenario: I'm working on a Log class that my app will use to write debug/error/etc messages to a file. I've created it so that as the application logs messages, these messages are queued within a property of the Log class, and only written to the file when the Log object is being destroyed. I wanted to place all of the file writing to within __destruct() to avoid holding a connection to the log file throughout the life of the app's state. Problem: Everything works fine, UNLESS I move the fopen('log-file-name') call to within the __destruct() method. If I open a handle to the log file within the __construct() method, or any other class method, it works fine. But I receive a permissions error if it's called within __destruct(). Error reads: Warning: fopen(20060331.txt) [function.fopen]: failed to open stream: Permission denied in ... Caveat: I have found that if I explicitly destroy an instance of Log with unset(), then fopen() will work even when it is within the __destruct() method. However I don't like that solution...and besides, I'm planning on creating an instance of the Log class from within the __construct() of my Controller class, and trying to explicitly destroy Log with an implicit __destruct() of my Controller doesn't work either. :P that's probably due to references still existing (according to the engine) to you Log object. Question(s): 1. Could anyone explain a bit more as to why fopen() won't work within an implicit call to __destruct()? What permissions has my app lost at this point? it's seems rather odd that the error would return a permission problem. I don't get that at all. 2. Am I at least correct in my intention to limit the duration that the handle to the log file is open? it's a good idea yes - any system will have some kind of max as to the number of open files that are allowed/capable. 3. Is there workaround to this little conundrum that anyone can think of? explicit destruction. may try working with register_shutdown_function() - the ctor of your log object could register a 'flsuh' method to be run at shutdown (which may well be at an early enough stage that opening/writing files is still possible) personally I avoid __destruct() - it gives me headaches and never seems capable of doing what I think it should be able to! Code: Here's a simplified version of the code (it's complete, feel free to copy-and-paste-and-play). I've commented the fopen code block in question. [code] // Create an instance of Log $log = new Log(); // Attempt to log a message Log::debug(Here is a debug message.); class Log { protected static $handle; protected static $location; protected static $message; public function __construct() { self::$location = date(Ymd)..txt; /* Begin fopen() */ /* When placed here, it works */ if (!self::$handle = fopen(self::$location,a)) { echo Error. Please check permissions.; die; } /* End fopen() */ } public static function debug($message) { $timestamp = date(Y-m-d H:i:s T); self::$message .= $timestamp.\tdebug\t.$message.\n; } public function __destruct() { if(self::$message) { /* Begin fopen() */ /* If it's here, it won't work! if (!self::$handle = fopen(self::$location,a)) { echo There was an error attempting to open the log file. Please check permissions.; die; } /* End fopen() */ if (fwrite(self::$handle, self::$message) === FALSE) { echo Cannot write to file ({$this-location}); exit; the 'die' and 'exit' in the code directly above is probably a really bad idea! and given that the code is currently living in a dtor rather unnecessary
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jasper Bryant-Greene wrote: Jochem Maas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: I think its a misunderstanding on the one side and a limitation on the other, you can't use overloading directly on items of an overloaded array e.g: echo $tc-arr['a'] this is triggers a call to __get() with the $key parameter set to something like (I'm guessing) arr['a'] No, I'm pretty sure (too lazy and tired right now to test...) that if you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this-var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t-arr = array(); $t-arr[a] = 1; echo OUTPUT: \n; var_dump($t-arr); var_dump($t-arr[a]); var_dump($t); ' That's weird, because I did get around to testing it before I saw your mail, and in my test it works as *I* expect (PHP 5.1.2)... My comments earlier were based on the fact that it would not be good to limit what can be put in an object through __get and __set effectively to scalar variables, and I would expect the engine developers to realise that. I think they have (unless I've done something stupid in my test code...): Code: ?php class T { private $array = array(); public function __get( $key ) { return $this-array[$key]; } public function __set( $key, $value ) { $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray['test'] = 'testing!'; var_dump( $t ); ? Output: object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } } Dont know if you guys see the MAJOR difference between your code, so I will point it out. Jasper did this function __get($k) { var_dump($k); } Jochem did this public function __get( $key ) { return $this-array[$key]; } First off, the required public before the function call was not included, secondly, Jasper is var_dumping the key of the array, not the array it self. Hope this helps And yes, it should work the way Jochem was expecting. At least that is what the manual says, and my testing says. But you have to make sure you include all the needed parts to make it work correctly. Thanks Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Going loopy with arrays.....
Howdy all! Here is hoping that Friday is just another day in paradise for everyone. I have an array, a multi-dimensional array. I need to either a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. Here is a sample; Array ( [H7] = Array ( [0] = Array ( [lon] = -99.2588 [lat] = 29.1918 ) [1] = Array ( [lon] = -99.2205 [lat] = 29.1487 ) [2] = Array ( [lon] = -99.23 [lat] = 29.1575 ) [3] = Array ( [lon] = -99.242 [lat] = 29.1545 ) ) [H6] = Array ( [0] = Array ( [lon] = -99.0876 [lat] = 29.216 ) [1] = Array ( [lon] = -99.0618 [lat] = 29.179 ) And so on I am sure that it has something to do with my lack of sleep and the looming of deadlines and this being something that I thought would be trivial. Can someone drop-kick me in the right direction please? The sub arrays need to be the points in each of the arrays with a H identifier (H7, H6 etc.) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
foreach ($parent as $child) { print $parent; foreach ($child as $item) { print $child . = . $item; } } didn't test it, but this should work. On 3/31/06, Jay Blanchard [EMAIL PROTECTED] wrote: Howdy all! Here is hoping that Friday is just another day in paradise for everyone. I have an array, a multi-dimensional array. I need to either a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. Here is a sample; Array ( [H7] = Array ( [0] = Array ( [lon] = -99.2588 [lat] = 29.1918 ) [1] = Array ( [lon] = -99.2205 [lat] = 29.1487 ) [2] = Array ( [lon] = -99.23 [lat] = 29.1575 ) [3] = Array ( [lon] = -99.242 [lat] = 29.1545 ) ) [H6] = Array ( [0] = Array ( [lon] = -99.0876 [lat] = 29.216 ) [1] = Array ( [lon] = -99.0618 [lat] = 29.179 ) And so on I am sure that it has something to do with my lack of sleep and the looming of deadlines and this being something that I thought would be trivial. Can someone drop-kick me in the right direction please? The sub arrays need to be the points in each of the arrays with a H identifier (H7, H6 etc.) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
[snip] foreach ($parent as $child) { print $parent; foreach ($child as $item) { print $child . = . $item; } } didn't test it, but this should work. [/snip] Didn't work, returns ArrayArray=ArrayArrayArray=ArrayArray=Array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: setting the same value to multiple variables
You could use variable variables with an array, like this: $arr = array('readingGoalsEnjoymentLabelClass','readingGoalsInformationLabelClass', 'readingGoalsAlphabeticLabelClass','readingGoalsPrintLabelClass', 'readingGoalsPhonologicalLabelClass','readingGoalsPhoneticLabelClass', 'readingGoalsComprehensionLabelClass','readingGoalsVocabularyLabelClass', 'readingGoalsInstructionsLabelClass','readingGoalsCriticalLabelClass', 'readingGoalsCommunicateLabelClass'); foreach ($arr as $var) { ${$var} = 'class=errorHere'; } /* This is to check if it was done correctly. */ foreach ($arr as $var) { echo $var = ${$var}\n; } charles stuart escribió: Hi, I'm sure this is quite basic. Nonetheless I'm new to PHP so I haven't figured it out. I'd like to set each variable to the same value (without having to set that value individually for each variable). Thanks for the help. best, Charles if ( 1 == 1 ) { $goodToGo = 0; $errorArray[] = You must declare some goals on Activity 1.; // this block of code does not set each variable to class=\errorHere\; $readingGoalsEnjoymentLabelClass $readingGoalsInformationLabelClass $readingGoalsAlphabeticLabelClass $readingGoalsPrintLabelClass $readingGoalsPhonologicalLabelClass $readingGoalsPhoneticLabelClass $readingGoalsComprehensionLabelClass $readingGoalsVocabularyLabelClass $readingGoalsInstructionsLabelClass $readingGoalsCriticalLabelClass $readingGoalsCommunicateLabelClass = class=\errorHere\; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
can you paste the array you're using? On 3/31/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] foreach ($parent as $child) { print $parent; foreach ($child as $item) { print $child . = . $item; } } didn't test it, but this should work. [/snip] Didn't work, returns ArrayArray=ArrayArrayArray=ArrayArray=Array -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: setting the same value to multiple variables
($a, $b) = $c; On 3/31/06, Eduardo Raúl Galván Sánchez [EMAIL PROTECTED] wrote: You could use variable variables with an array, like this: $arr = array('readingGoalsEnjoymentLabelClass','readingGoalsInformationLabelClass', 'readingGoalsAlphabeticLabelClass','readingGoalsPrintLabelClass', 'readingGoalsPhonologicalLabelClass','readingGoalsPhoneticLabelClass', 'readingGoalsComprehensionLabelClass','readingGoalsVocabularyLabelClass', 'readingGoalsInstructionsLabelClass','readingGoalsCriticalLabelClass', 'readingGoalsCommunicateLabelClass'); foreach ($arr as $var) { ${$var} = 'class=errorHere'; } /* This is to check if it was done correctly. */ foreach ($arr as $var) { echo $var = ${$var}\n; } charles stuart escribió: Hi, I'm sure this is quite basic. Nonetheless I'm new to PHP so I haven't figured it out. I'd like to set each variable to the same value (without having to set that value individually for each variable). Thanks for the help. best, Charles if ( 1 == 1 ) { $goodToGo = 0; $errorArray[] = You must declare some goals on Activity 1.; // this block of code does not set each variable to class=\errorHere\; $readingGoalsEnjoymentLabelClass $readingGoalsInformationLabelClass $readingGoalsAlphabeticLabelClass $readingGoalsPrintLabelClass $readingGoalsPhonologicalLabelClass $readingGoalsPhoneticLabelClass $readingGoalsComprehensionLabelClass $readingGoalsVocabularyLabelClass $readingGoalsInstructionsLabelClass $readingGoalsCriticalLabelClass $readingGoalsCommunicateLabelClass = class=\errorHere\; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML-RPC or SOAP
I want to take a mysql database that I have and turn it into a wsdl page where I can make a client program connect to. I have read how to do it in Tomcat. but looking for help in using PHP. On Mar 30, 2006, at 9:45 PM, Anthony Ettinger wrote: what about WSDL? On 3/30/06, Russell Jones [EMAIL PROTECTED] wrote: I would go with XML-RPC. I currently use XML-RPC to run LinkSleeve - a link-spam detection tool. In my opinion, I have found XML-RPC to be easier to use and understand. If at any point in your product you will be dealing with customers / vendors who will be beginners with both XML-RPC and SOAP, I would say the learning curve for XML-RPC is much lower. I do feel, however, that SOAP is potentially a more robust solution. Anyway, just my 2 cents and, good luck. On 3/30/06, Philip Hallstrom [EMAIL PROTECTED] wrote: I am at the beginning of creating a web service. As I am not very familar with both SOAP and XML-RPC it would not make much difference in which one I learn. Which one would you guys recommend for a web app that has to be transformed into a white lable solution. I just did one using SOAP. Seems to work just fine. Just be sure to get the WSDL generator from here: http://www.schlossnagle.org/~george/php/WSDL_Gen.tgz We did it using PHP5's soap extension. good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: setting the same value to multiple variables
Anthony Ettinger wrote: ($a, $b) = $c; ^^ I don't get the meaning of this... On 3/31/06, Eduardo Raúl Galván Sánchez [EMAIL PROTECTED] wrote: You could use variable variables with an array, like this: $arr = array('readingGoalsEnjoymentLabelClass','readingGoalsInformationLabelClass', 'readingGoalsAlphabeticLabelClass','readingGoalsPrintLabelClass', 'readingGoalsPhonologicalLabelClass','readingGoalsPhoneticLabelClass', 'readingGoalsComprehensionLabelClass','readingGoalsVocabularyLabelClass', 'readingGoalsInstructionsLabelClass','readingGoalsCriticalLabelClass', 'readingGoalsCommunicateLabelClass'); foreach ($arr as $var) { ${$var} = 'class=errorHere'; } /* This is to check if it was done correctly. */ foreach ($arr as $var) { echo $var = ${$var}\n; } charles stuart escribió: Hi, I'm sure this is quite basic. Nonetheless I'm new to PHP so I haven't figured it out. I'd like to set each variable to the same value (without having to set that value individually for each variable). Thanks for the help. best, Charles if ( 1 == 1 ) { $goodToGo = 0; $errorArray[] = You must declare some goals on Activity 1.; // this block of code does not set each variable to class=\errorHere\; $readingGoalsEnjoymentLabelClass $readingGoalsInformationLabelClass $readingGoalsAlphabeticLabelClass $readingGoalsPrintLabelClass $readingGoalsPhonologicalLabelClass $readingGoalsPhoneticLabelClass $readingGoalsComprehensionLabelClass $readingGoalsVocabularyLabelClass $readingGoalsInstructionsLabelClass $readingGoalsCriticalLabelClass $readingGoalsCommunicateLabelClass = class=\errorHere\; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
[snip] can you paste the array you're using? [/snip] It was in the original post. Array ( [H7] = Array ( [0] = Array ( [lon] = -99.2588 [lat] = 29.1918 ) [1] = Array ( [lon] = -99.2205 [lat] = 29.1487 ) [2] = Array ( [lon] = -99.23 [lat] = 29.1575 ) [3] = Array ( [lon] = -99.242 [lat] = 29.1545 ) ) [H6] = Array ( [0] = Array ( [lon] = -99.0876 [lat] = 29.216 ) [1] = Array ( [lon] = -99.0618 [lat] = 29.179 ) } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
that's a dump of the arraycan you paste the source? On 3/31/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] can you paste the array you're using? [/snip] It was in the original post. Array ( [H7] = Array ( [0] = Array ( [lon] = -99.2588 [lat] = 29.1918 ) [1] = Array ( [lon] = -99.2205 [lat] = 29.1487 ) [2] = Array ( [lon] = -99.23 [lat] = 29.1575 ) [3] = Array ( [lon] = -99.242 [lat] = 29.1545 ) ) [H6] = Array ( [0] = Array ( [lon] = -99.0876 [lat] = 29.216 ) [1] = Array ( [lon] = -99.0618 [lat] = 29.179 ) } } -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: setting the same value to multiple variables
nevermind, that doesn't work...after testing it :*( i've seen it in perlregex. On 3/31/06, Eduardo Raúl Galván Sánchez [EMAIL PROTECTED] wrote: Anthony Ettinger wrote: ($a, $b) = $c; ^^ I don't get the meaning of this... On 3/31/06, Eduardo Raúl Galván Sánchez [EMAIL PROTECTED] wrote: You could use variable variables with an array, like this: $arr = array('readingGoalsEnjoymentLabelClass','readingGoalsInformationLabelClass', 'readingGoalsAlphabeticLabelClass','readingGoalsPrintLabelClass', 'readingGoalsPhonologicalLabelClass','readingGoalsPhoneticLabelClass', 'readingGoalsComprehensionLabelClass','readingGoalsVocabularyLabelClass', 'readingGoalsInstructionsLabelClass','readingGoalsCriticalLabelClass', 'readingGoalsCommunicateLabelClass'); foreach ($arr as $var) { ${$var} = 'class=errorHere'; } /* This is to check if it was done correctly. */ foreach ($arr as $var) { echo $var = ${$var}\n; } charles stuart escribió: Hi, I'm sure this is quite basic. Nonetheless I'm new to PHP so I haven't figured it out. I'd like to set each variable to the same value (without having to set that value individually for each variable). Thanks for the help. best, Charles if ( 1 == 1 ) { $goodToGo = 0; $errorArray[] = You must declare some goals on Activity 1.; // this block of code does not set each variable to class=\errorHere\; $readingGoalsEnjoymentLabelClass $readingGoalsInformationLabelClass $readingGoalsAlphabeticLabelClass $readingGoalsPrintLabelClass $readingGoalsPhonologicalLabelClass $readingGoalsPhoneticLabelClass $readingGoalsComprehensionLabelClass $readingGoalsVocabularyLabelClass $readingGoalsInstructionsLabelClass $readingGoalsCriticalLabelClass $readingGoalsCommunicateLabelClass = class=\errorHere\; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
[snip] that's a dump of the arraycan you paste the source? [/snip] Not really. The original array was manipulated to get the point (H) groups together for the new array so that I could break the points back out together (they are not together in the original file). Here is how I got there A sample of the text file (someone else providing); H7-99.211729.087 H7-99.214629.087 H7-99.186429.1026 H7-99.180729.0837 H7-99.166829.0619 H6-99.087629.216 H6-99.061829.179 H6-99.069929.1652 H6-99.069929.166 H6-99.076129.1765 H6-99.076129.1879 H6-99.075229.1895 H6-99.102 29.2353 H6-99.129329.2503 H6-99.128829.2524 H6-99.126429.2738 H6-99.124 29.2764 H6-99.107829.281 H6-99.106329.2806 H6-99.090129.2642 H6-99.088129.2642 H6-99.076229.2684 H6-99.069 29.2785 H6-99.068529.2793 H6-99.064729.2806 $mapFile3 = fopen(inc/Outdoor_HolesH1-H7.txt, r); $op = 0; while(!feof($mapFile3)){ $mapLine = fgets($mapFile3, 4096); if( != $mapLine){ $mapLineArr = explode(\t, $mapLine); $mapArray3[$op]['id'] = str_replace(\, ,$mapLineArr[0]); $mapArray3[$op]['lon'] = $mapLineArr[count($mapLineArr)-2]; $mapArray3[$op]['lat'] = $mapLineArr[count($mapLineArr)-1]; $op++; } } fclose($mapFile3); function groupByFirst($array) { foreach ($array as $row) { $firstKey = array_keys($row); $firstKey = $firstKey[0]; $key = $row[$firstKey]; unset($row[$firstKey]); $newArray[$key][] = $row; } return $newArray; } $new = groupByFirst($mapArray3); print_r($new); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. This might help get you going in the right direction... script language=php function print_elements( $var ) { if( is_array( $var )) { foreach( $var as $k = $v ) { if( is_array( $v )) { print_elements( $v ); } else { echo $k = $vbr; } } } } $array = array(); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1918 ); $array['H7'][] = array( 'lon' = -99.2205, 'lat' = 29.1487 ); $array['H7'][] = array( 'lon' = -99.242, 'lat' = 29.1575 ); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1545 ); $array['H6'][] = array( 'lon' = -99.0876, 'lat' = 29.216 ); $array['H6'][] = array( 'lon' = -99.0618, 'lat' = 29.179 ); array_walk( $array, 'print_elements' ); /script thnx, Chris
RE: [PHP] Going loopy with arrays.....
[snip] a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. This might help get you going in the right direction... script language=php function print_elements( $var ) { if( is_array( $var )) { foreach( $var as $k = $v ) { if( is_array( $v )) { print_elements( $v ); } else { echo $k = $vbr; } } } } $array = array(); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1918 ); $array['H7'][] = array( 'lon' = -99.2205, 'lat' = 29.1487 ); $array['H7'][] = array( 'lon' = -99.242, 'lat' = 29.1575 ); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1545 ); $array['H6'][] = array( 'lon' = -99.0876, 'lat' = 29.216 ); $array['H6'][] = array( 'lon' = -99.0618, 'lat' = 29.179 ); array_walk( $array, 'print_elements' ); /script [snip] Okay, that is cool too, but it still lacks one key ingredient, I need to know which 'H' each lat an lon belongs to. Here is the pseudo-code for what I am attempting, I fear I may not have explained myself clearly enough earlier; Loop Get the current H While current H output the points of current H end while next H End loop It is gotten to the point where I am tempted to put each H in its own file, open it, do the stuff, close it, go to the next file as it might have been quicker but I so wanted to do this with the array. The complication is that when the file is sent the H's are not in order, so they have to be grouped together (with changing their order in the file) so that the output occurs logically. Thanks everyone! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
Yeah, that foreach is outright printing the arrays (foreach $parent... print $parent?) I'm guessing you wouldn't ask this, Jay, unless there was an issue with not knowing the depth of the data. I saw something once with doing recursive function calls to dig down into an array or something. So it'd be something like this: function finddata($arr) { foreach ($arr as $key = $value) { if (substr($key, 0, 1) == H) { echo bi$key/i/bbr\n; foreach ($value as $subkey = $subvalue) { echo [$subkey] lat: . $subvalue[lat] . long: . $subvalue[lon] . br\n; } } else { finddata($value); } } } finddata($mainarray); Something like that.. my brain's working at 50% today as it is, but maybe this gives you a nudge in the right direction. -TG = = = Original message = = = [snip] foreach ($parent as $child) print $parent; foreach ($child as $item) print $child . = . $item; didn't test it, but this should work. [/snip] Didn't work, returns ArrayArray=ArrayArrayArray=ArrayArray=Array ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Types for Upload
For an expression such as this. $HTTP_POST_FILES['userfile']['type']==image/gif I'm looking for an up to date list of all the other media formats (non-images), such as Video and Audio. Does anyone have a list handy they could direct me to. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
[snip] I'm guessing you wouldn't ask this, Jay, unless there was an issue with not knowing the depth of the data. [/snip] Exactly. I have another department that sends the data as text files and I knew that I could send them to a database and all would be well, or relatively so. But that adds a layer of complexity. If I can have the department upload the file (I know, I could parse the uploaded file etc. etc...but this needs to be quick...or needed to be) or just save it to the proper location then I wouldn't have to worry about the updates, unless something failed. I have set a couple of rules that the file must follow, but they can do anything else that they want to (and they will) with the file. Given your suggestion I am working a solution now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: File Types for Upload
IANA has the most updated oficial MIME types: http://www.iana.org/assignments/media-types/ Kevin Murphy escribió: For an expression such as this. $HTTP_POST_FILES['userfile']['type']==image/gif I'm looking for an up to date list of all the other media formats (non-images), such as Video and Audio. Does anyone have a list handy they could direct me to. --Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
Yeah.. or something like this! (Chris' looks better than mine.. maybe his brain's working at 70% today :) -TG = = = Original message = = = a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. This might help get you going in the right direction... script language=php function print_elements( $var ) if( is_array( $var )) foreach( $var as $k = $v ) if( is_array( $v )) print_elements( $v ); else echo $k = $vbr; $array = array(); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1918 ); $array['H7'][] = array( 'lon' = -99.2205, 'lat' = 29.1487 ); $array['H7'][] = array( 'lon' = -99.242, 'lat' = 29.1575 ); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1545 ); $array['H6'][] = array( 'lon' = -99.0876, 'lat' = 29.216 ); $array['H6'][] = array( 'lon' = -99.0618, 'lat' = 29.179 ); array_walk( $array, 'print_elements' ); /script thnx, Chris ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Going loopy with arrays.....
If you need to backtrack from the lat/long to the H key, why not build a reverse lookup array? $arr[$lat . : . $long] = $hvalue; ? -TG = = = Original message = = = [snip] a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. This might help get you going in the right direction... script language=php ~ function print_elements( $var ) ~~~ if( is_array( $var )) ~ foreach( $var as $k = $v ) ~~~ if( is_array( $v )) ~ print_elements( $v ); ~~~ else ~ echo $k~ = $vbr; ~~~ ~ ~~~ ~ ~ $array = array(); ~ $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1918 ); ~ $array['H7'][] = array( 'lon' = -99.2205, 'lat' = 29.1487 ); ~ $array['H7'][] = array( 'lon' = -99.242, 'lat' = 29.1575 ); ~ $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1545 ); ~ $array['H6'][] = array( 'lon' = -99.0876, 'lat' = 29.216 ); ~ $array['H6'][] = array( 'lon' = -99.0618, 'lat' = 29.179 ); ~ array_walk( $array, 'print_elements' ); /script [snip] Okay, that is cool too, but it still lacks one key ingredient, I need to know which 'H' each lat an lon belongs to. Here is the pseudo-code for what I am attempting, I fear I may not have explained myself clearly enough earlier; Loop Get the current H While current H output the points of current H end while next H End loop It is gotten to the point where I am tempted to put each H in its own file, open it, do the stuff, close it, go to the next file as it might have been quicker but I so wanted to do this with the array. The complication is that when the file is sent the H's are not in order, so they have to be grouped together (with changing their order in the file) so that the output occurs logically. Thanks everyone! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image resizing problems
I'm pulling my hair out with this gd resizing of an image, and can't figure out where it's screwing up. I've been trying to batch process about 500 images to resize them to a standard size, and for some reason, instead of resizing the image, it's just taking a corner of the original image... $orgimg = imagecreatefromjpeg ( $image_data['image_path'] ); imagecopyresampled ( $im, $orgimg, 0, 0, 0, 0, 250, 250, 600, 600 ); imagejpeg ( $im, $path . $file_name . .temp ); The original images are 600x600, and I'm trying to shrink it down to 250x250, but when I run it thru this it just gives me a 250x250 image which looks to be cropped from the original image (not resized, just the top left corner). This is too much thinking for a Friday. What am I missing??? -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image resizing problems
Have you tried imagecopy resized()? John Nichel escribió: I'm pulling my hair out with this gd resizing of an image, and can't figure out where it's screwing up. I've been trying to batch process about 500 images to resize them to a standard size, and for some reason, instead of resizing the image, it's just taking a corner of the original image... $orgimg = imagecreatefromjpeg ( $image_data['image_path'] ); imagecopyresampled ( $im, $orgimg, 0, 0, 0, 0, 250, 250, 600, 600 ); imagejpeg ( $im, $path . $file_name . .temp ); The original images are 600x600, and I'm trying to shrink it down to 250x250, but when I run it thru this it just gives me a 250x250 image which looks to be cropped from the original image (not resized, just the top left corner). This is too much thinking for a Friday. What am I missing??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image resizing problems
on http://nl2.php.net/manual/en/function.imagecopyresampled.php is an example how to use it when you are resizing images, I think you are putting some numbers on the wrong place On 3/31/06, John Nichel [EMAIL PROTECTED] wrote: I'm pulling my hair out with this gd resizing of an image, and can't figure out where it's screwing up. I've been trying to batch process about 500 images to resize them to a standard size, and for some reason, instead of resizing the image, it's just taking a corner of the original image... $orgimg = imagecreatefromjpeg ( $image_data['image_path'] ); imagecopyresampled ( $im, $orgimg, 0, 0, 0, 0, 250, 250, 600, 600 ); imagejpeg ( $im, $path . $file_name . .temp ); The original images are 600x600, and I'm trying to shrink it down to 250x250, but when I run it thru this it just gives me a 250x250 image which looks to be cropped from the original image (not resized, just the top left corner). This is too much thinking for a Friday. What am I missing??? -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Image resizing problems
Eduardo Raúl Galván Sánchez wrote: Have you tried imagecopy resized()? Same results with that. I'm using imagecopyresampled to keep the quality as high as possible. John Nichel escribió: I'm pulling my hair out with this gd resizing of an image, and can't figure out where it's screwing up. I've been trying to batch process about 500 images to resize them to a standard size, and for some reason, instead of resizing the image, it's just taking a corner of the original image... $orgimg = imagecreatefromjpeg ( $image_data['image_path'] ); imagecopyresampled ( $im, $orgimg, 0, 0, 0, 0, 250, 250, 600, 600 ); imagejpeg ( $im, $path . $file_name . .temp ); The original images are 600x600, and I'm trying to shrink it down to 250x250, but when I run it thru this it just gives me a 250x250 image which looks to be cropped from the original image (not resized, just the top left corner). This is too much thinking for a Friday. What am I missing??? -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image resizing problems [SOLVED]
John Nichel wrote: I'm pulling my hair out with this gd resizing of an image, and can't figure out where it's screwing up. I've been trying to batch process about 500 images to resize them to a standard size, and for some reason, instead of resizing the image, it's just taking a corner of the original image... $orgimg = imagecreatefromjpeg ( $image_data['image_path'] ); imagecopyresampled ( $im, $orgimg, 0, 0, 0, 0, 250, 250, 600, 600 ); imagejpeg ( $im, $path . $file_name . .temp ); The original images are 600x600, and I'm trying to shrink it down to 250x250, but when I run it thru this it just gives me a 250x250 image which looks to be cropped from the original image (not resized, just the top left corner). This is too much thinking for a Friday. What am I missing??? *DOH* Nevermind. Friday. To close to beer-thirty. It's working fine. I was looking at the images on our staging server, but running the script on our development server. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Database Connections (cont..)
Hey all, Ok, spoke to the boss and he has agreed for me to give you the following info; Heres what the app does: - Clients add their sites in their client control panel which we give them at our site - Client installs our script on his server, every time someone logs in their username is sent to us along with their IP and other details (cant reveal due to NDA but unimportant in this emails context) - we take the username and query the db to see if this username already exists and what parameters this username has set -- we update the database for statistics -- we update this usernames parameters -- again run SQL statements 1-3 times (Other processing happens between the above points of course but not related to the database so I didn't write them and some points couldn't write due to the NDA - my apologies once again) NOTE: The above is for _one_ username and _one site_ . eventually there will be hundreds of sites and each site will have X number of usernames which will be sent to us for processing. If this project goes well and once we can afford it this will be moved to a dedicated box but till then... do you guys foresee any problems with PHP-database-PHP Running Chris' SQL: show status like '%connection%'; gave me these results: Connections 49029 Max_used_connections 109 I was also looking at mysql_pconnect() and reading up about it at php.net, most of the comments say to actually avoid it, but reading what i wrote on top what do you say? any alternate suggestions as usual are most welcome too. Right now I'm using the normal mysql_connect() We are using just one mysql database with around 7 tables - trying to keep this as simple as possible Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL close connection, what's the purpose?
Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into 200 other MySQL servers, as a sort of home-brew replication (which would be really dumb to do, mind you)... In that case, you REALLY don't want the overhead of all 200 connections open, so after you finish each one, you would close it. There are also cases where you finish your MySQL work, but have a TON of other stuff to do in the script, which will not require MySQL. Close the connection to free up the resource, like a good little boy. :-) There also COULD be cases where your PHP script is not ending properly, and you'd be better off to mysql_close() yourself. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into 200 other MySQL servers, as a sort of home-brew replication (which would be really dumb to do, mind you)... In that case, you REALLY don't want the overhead of all 200 connections open, so after you finish each one, you would close it. There are also cases where you finish your MySQL work, but have a TON of other stuff to do in the script, which will not require MySQL. Close the connection to free up the resource, like a good little boy. :-) There also COULD be cases where your PHP script is not ending properly, and you'd be better off to mysql_close() yourself. So, does the connection close automatically at the end of the script ? My situation is following: I have a e-shop with a ridiculously small amount of max approved connections, so it gives an error to about 10% of my visitors a day, that the mysql connections were exceeded. Now, if I will delete the mysql_close() line, will that help me or not? My webhosting does not allow perminent connections either. Thanks, MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
On 3/31/06, Martin Zvarík [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into 200 other MySQL servers, as a sort of home-brew replication (which would be really dumb to do, mind you)... In that case, you REALLY don't want the overhead of all 200 connections open, so after you finish each one, you would close it. There are also cases where you finish your MySQL work, but have a TON of other stuff to do in the script, which will not require MySQL. Close the connection to free up the resource, like a good little boy. :-) There also COULD be cases where your PHP script is not ending properly, and you'd be better off to mysql_close() yourself. So, does the connection close automatically at the end of the script ? My situation is following: I have a e-shop with a ridiculously small amount of max approved connections, so it gives an error to about 10% of my visitors a day, that the mysql connections were exceeded. Now, if I will delete the mysql_close() line, will that help me or not? My webhosting does not allow perminent connections either. Thanks, MZ deleting the mysql_close() line would keep the connection open until the script ends. by closing it earlier when you're done with the database for the event, your script continues on, ie - parsing/displaying of db query results, template rendering, etc. yet the connection was closed earlier so other processes can use mysql (assuming your hitting your limit this way with too many simultaneous connections). -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Database Connections (cont..)
I don't see a problem with that. My only suggestion is to have one table for each site, in order to avoid usernames of one site to colide with usernames from another site. Ryan A escribió: Hey all, Ok, spoke to the boss and he has agreed for me to give you the following info; Heres what the app does: - Clients add their sites in their client control panel which we give them at our site - Client installs our script on his server, every time someone logs in their username is sent to us along with their IP and other details (cant reveal due to NDA but unimportant in this emails context) - we take the username and query the db to see if this username already exists and what parameters this username has set -- we update the database for statistics -- we update this usernames parameters -- again run SQL statements 1-3 times (Other processing happens between the above points of course but not related to the database so I didn't write them and some points couldn't write due to the NDA - my apologies once again) NOTE: The above is for _one_ username and _one site_ . eventually there will be hundreds of sites and each site will have X number of usernames which will be sent to us for processing. If this project goes well and once we can afford it this will be moved to a dedicated box but till then... do you guys foresee any problems with PHP-database-PHP Running Chris' SQL: show status like '%connection%'; gave me these results: Connections 49029 Max_used_connections 109 I was also looking at mysql_pconnect() and reading up about it at php.net, most of the comments say to actually avoid it, but reading what i wrote on top what do you say? any alternate suggestions as usual are most welcome too. Right now I'm using the normal mysql_connect() We are using just one mysql database with around 7 tables - trying to keep this as simple as possible Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jim Lucas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: [snip] you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this-var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t-arr = array(); $t-arr[a] = 1; echo OUTPUT: \n; var_dump($t-arr); var_dump($t-arr[a]); var_dump($t); ' [snip] Code: ?php class T { private $array = array(); public function __get( $key ) { return $this-array[$key]; } public function __set( $key, $value ) { $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray['test'] = 'testing!'; var_dump( $t ); ? Output: object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } } Dont know if you guys see the MAJOR difference between your code, so I will point it out. Jasper did this function __get($k) { var_dump($k); } Uhm, no I didn't. Jochem did :) Jochem did this public function __get( $key ) { return $this-array[$key]; } No, I did that. First off, the required public before the function call was not included, secondly, Jasper is var_dumping the key of the array, not the array it self. Public is not required. I always put it regardless, but if you leave it off then PHP defaults to public for compatibility reasons. Jochem's code, which behaves incorrectly, does var_dump. Mine just returns the array key as you would expect. That's why Jochem's doesn't behave correctly with arrays. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next query? I don't see that as a good idea. -- 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] MySQL close connection, what's the purpose?
On 3/31/06, chris smith [EMAIL PROTECTED] wrote: On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next query? I don't see that as a good idea. No, you leave it open until you're done with the database. If you pee and poo in one sitting, you don't get up and flush between occurrences. -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Database Connections (cont..)
On 4/1/06, Ryan A [EMAIL PROTECTED] wrote: Hey all, Ok, spoke to the boss and he has agreed for me to give you the following info; Heres what the app does: - Clients add their sites in their client control panel which we give them at our site - Client installs our script on his server, every time someone logs in their username is sent to us along with their IP and other details (cant reveal due to NDA but unimportant in this emails context) - we take the username and query the db to see if this username already exists and what parameters this username has set -- we update the database for statistics -- we update this usernames parameters -- again run SQL statements 1-3 times (Other processing happens between the above points of course but not related to the database so I didn't write them and some points couldn't write due to the NDA - my apologies once again) NOTE: The above is for _one_ username and _one site_ . eventually there will be hundreds of sites and each site will have X number of usernames which will be sent to us for processing. are they emailed to you? are they done through a remote php script (http://www.domain.com/blah.php) ? If this project goes well and once we can afford it this will be moved to a dedicated box but till then... do you guys foresee any problems with PHP-database-PHP Sounds ok in theory. show status like '%connection%'; gave me these results: Connections 49029 Max_used_connections 109 Looks fine. Don't know whether you can tell whether your user has connection limits or not. I was also looking at mysql_pconnect() and reading up about it at php.net, most of the comments say to actually avoid it, but reading what i wrote on top what do you say? any alternate suggestions as usual are most welcome too. persistent connections are more pain than they are worth. Basically instead of opening a connection, then closing it at the end of the script, they open the connection, when the script ends, it's left open potentially for the next script to use. Good in theory but not great in practice. -- 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] MySQL close connection, what's the purpose?
On 4/1/06, Anthony Ettinger [EMAIL PROTECTED] wrote: On 3/31/06, chris smith [EMAIL PROTECTED] wrote: On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next query? I don't see that as a good idea. No, you leave it open until you're done with the database. Reading Ted's post didn't give this impression. I wanted to make sure he wasn't doing it that way. -- 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] Database connections
Chris wrote: Jasper Bryant-Greene wrote: Chris wrote: If they're accessing the same database you don't need to disconnect/reconnect. Different db's - well, yeh you don't have a choice. Of course you do. mysql_select_db() or whatever it's called. Or just issue a USE [databasename] query. No need to reconnect! Only if you are using the same username/password, but you're right, it is an option. the other option here would if he was having to change the user name and password would be http://us2.php.net/manual/en/function.mysql-change-user.php have fun Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database connections
On 4/1/06, Jim Lucas [EMAIL PROTECTED] wrote: Chris wrote: Jasper Bryant-Greene wrote: Chris wrote: If they're accessing the same database you don't need to disconnect/reconnect. Different db's - well, yeh you don't have a choice. Of course you do. mysql_select_db() or whatever it's called. Or just issue a USE [databasename] query. No need to reconnect! Only if you are using the same username/password, but you're right, it is an option. the other option here would if he was having to change the user name and password would be http://us2.php.net/manual/en/function.mysql-change-user.php I was going to say I didn't know that function existed, then noticed: 3.0.14 This function was removed from PHP. -- 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] Overloading Limitation- Can Someone Confirm?
could you both take a look at this (I posted it already btw) - notice that the second 'set' action ($t-insideArray[test] = testing!;) is not going via __set() at all, it uses __get() BUT/AND then an item is set in the returned array ... and also in the [sub] array stored inside the object (even though nothing is being returned by reference): (I feel that this is not right somehow!) ?php class T { private $array = array(); public function __get( $key ) { echo Getting $key\n; return $this-array[$key]; } public function __set( $key, $value ) { echo Setting $key\n; $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray[test] = testing!; var_dump( $t ); ? OUTPUT: Setting insideArray Getting insideArray object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } Jasper Bryant-Greene wrote: Jim Lucas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: [snip] you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this-var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t-arr = array(); $t-arr[a] = 1; echo OUTPUT: \n; var_dump($t-arr); var_dump($t-arr[a]); var_dump($t); ' [snip] Code: ?php class T { private $array = array(); public function __get( $key ) { return $this-array[$key]; } public function __set( $key, $value ) { $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray['test'] = 'testing!'; var_dump( $t ); ? Output: object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } } Dont know if you guys see the MAJOR difference between your code, so I will point it out. Jasper did this function __get($k) { var_dump($k); } Uhm, no I didn't. Jochem did :) Jochem did this public function __get( $key ) { return $this-array[$key]; } No, I did that. First off, the required public before the function call was not included, secondly, Jasper is var_dumping the key of the array, not the array it self. Public is not required. I always put it regardless, but if you leave it off then PHP defaults to public for compatibility reasons. Jochem's code, which behaves incorrectly, does var_dump. Mine just returns the array key as you would expect. That's why Jochem's doesn't behave correctly with arrays. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
Jay Blanchard wrote: Howdy all! Here is hoping that Friday is just another day in paradise for everyone. I have an array, a multi-dimensional array. I need to either a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. Does this second option mean that instead of this $arr['H7'][0][lon] = 23.233; you want to have it $H7[0][lon] = 23.233; Would that be what you want? if so, check out extract() I think it is just what you are looking for. Jim Here is a sample; Array ( [H7] = Array ( [0] = Array ( [lon] = -99.2588 [lat] = 29.1918 ) [1] = Array ( [lon] = -99.2205 [lat] = 29.1487 ) [2] = Array ( [lon] = -99.23 [lat] = 29.1575 ) [3] = Array ( [lon] = -99.242 [lat] = 29.1545 ) ) [H6] = Array ( [0] = Array ( [lon] = -99.0876 [lat] = 29.216 ) [1] = Array ( [lon] = -99.0618 [lat] = 29.179 ) And so on I am sure that it has something to do with my lack of sleep and the looming of deadlines and this being something that I thought would be trivial. Can someone drop-kick me in the right direction please? The sub arrays need to be the points in each of the arrays with a H identifier (H7, H6 etc.) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CakePHP Undefined variable
Hi everyone! I use CakePHP. I found an error. Could you help me to deal this error. Notice: Undefined variable: missing in c:\Inetpub\wwwroot\Cake\app\views\errors\missing_controller.php on line 18 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to debug in CakePHP.
Hi everybody! I use cake, I have an error, but I can't find where the error occurs. Have any tools for debug? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CakePHP Undefined variable
On 4/1/06, Pham Huu Le Quoc Phuc [EMAIL PROTECTED] wrote: Hi everyone! I use CakePHP. I found an error. Could you help me to deal this error. Notice: Undefined variable: missing in c:\Inetpub\wwwroot\Cake\app\views\errors\missing_controller.php on line 18 You're trying to use a variable that isn't set yet: ?php echo my favourite colour is $colourbr/; ? You need to set your variable ('missing') before using it. -- 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] How to debug in CakePHP.
Hi everybody! I use cake, I have an error, but I can't find where the error occurs. Have any tools for debug? Set up an error log. Edit your php.ini file and set: log_errors = On error_log = /path/to/logfile.log then errors will get put in the logfile and you'll be able to track them down. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_match
I'm trying to check a string for ../ ?php if(preg_match(/..//i, $string)){ echo string has ../; } ? Can't get it to work can anyone help? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match
Benjamin D Adams wrote: I'm trying to check a string for ../ ?php if(preg_match(/..//i, $string)){ echo string has ../; } ? Can't get it to work can anyone help? That's terrible overkill. Regex is not designed for simple substring matching. You want: if( strpos( $string, '../' ) !== false ) echo 'string has ../'; By the way, your problem is that . is a special character in regular expressions, so needs escaping with a backslash, and you have used / as your delimiter but also use it inside the pattern. You should use a different delimiter (also, there's no point in using the 'i' case-insensitive flag, since there's no characters in your pattern). The strpos() solution above is much better and faster in this case, though. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to debug in CakePHP.
chris smith wrote: Hi everybody! I use cake, I have an error, but I can't find where the error occurs. Have any tools for debug? Set up an error log. Edit your php.ini file and set: log_errors = On error_log = /path/to/logfile.log then errors will get put in the logfile and you'll be able to track them down. And for heaven's sake, RTFM and http://tinyurl.com/anel -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match
On 4/1/06, Benjamin D Adams [EMAIL PROTECTED] wrote: I'm trying to check a string for ../ ?php if(preg_match(/..//i, $string)){ echo string has ../; } ? Can't get it to work can anyone help? Since / is your delimiter you need to escape it. Also '.' means anything so you need to escape that as well. if (preg_match('/\.\.\//', $string)) ... What are you trying to achieve? There may be a better way than using a regular expression. -- 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] Overloading Limitation- Can Someone Confirm?
Chr is wrote: You're right, it's not going through the __Set() method a second time. If you REALLY want to get confused by overloading behavior try the following code using your T class: $t = new T; $t-insideArray = array('a' = 'A', 'b' = 'B', 'c' = 'C'); foreach ($t-insideArray as $k = $v) { $t-insideArray[$k] = null; } if (count($t-insideArray) 0) { foreach ($t-insideArray as $k = $v) { echo $v; } } var_dump($t); Why does count() return 0? Why has $t-insideArray become NULL instead of an empty array? I can't tell you because I don't have access to a 5.1.2 CLI at the moment. I can tell you that this leads to a SegFault on 5.0.4, here is the output: Setting insideArray Getting insideArray Getting insideArray Getting insideArray Getting insideArray Getting insideArray Segmentation fault and on 5.1.1 it's not much better, the output is: Setting insideArray Getting insideArray Getting insideArray Getting insideArray Getting insideArray Getting insideArray Getting insideArray FATAL: emalloc(): Unable to allocate 1916888421 bytes Chris [EMAIL PROTECTED] On Mar 31, 2006, at 7:39 PM, Jochem Maas wrote: could you both take a look at this (I posted it already btw) - notice that the second 'set' action ($t-insideArray[test] = testing!;) is not going via __set() at all, it uses __get() BUT/AND then an item is set in the returned array ... and also in the [sub] array stored inside the object (even though nothing is being returned by reference): (I feel that this is not right somehow!) ?php class T { private $array = array(); public function __get( $key ) { echo Getting $key\n; return $this-array[$key]; } public function __set( $key, $value ) { echo Setting $key\n; $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray[test] = testing!; var_dump( $t ); ? OUTPUT: Setting insideArray Getting insideArray object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } Jasper Bryant-Greene wrote: Jim Lucas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: [snip] you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this-var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t-arr = array(); $t-arr[a] = 1; echo OUTPUT: \n; var_dump($t-arr); var_dump($t-arr[a]); var_dump($t); ' [snip] Code: ?php class T { private $array = array(); public function __get( $key ) { return $this-array[$key]; } public function __set( $key, $value ) { $this-array[$key] = $value; } } $t = new T; $t-insideArray = array(); $t-insideArray['test'] = 'testing!'; var_dump( $t ); ? Output: object(T)#1 (1) { [array:private]= array(1) { [insideArray]= array(1) { [test]= string(8) testing! } } } Dont know if you guys see the MAJOR difference between your code, so I will point it out. Jasper did this function __get($k) { var_dump($k); } Uhm, no I didn't. Jochem did :) Jochem did this public function __get( $key ) { return $this-array[$key]; } No, I did that. First off, the required public before the function call was not included, secondly, Jasper is var_dumping the key of the array, not the array it self. Public is not required. I always put it regardless, but if you leave it off then PHP defaults to public for compatibility reasons. Jochem's code, which behaves incorrectly, does var_dump. Mine just returns the array key as you would expect. That's why Jochem's doesn't behave correctly with arrays. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php