[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch
On Wed, 27 Nov 2002, Andi Gutmans wrote: At 04:41 PM 11/26/2002 -0500, Daniel Cowgill wrote: So why do the conversion in arithmetic? This seems bizarrely inconsistent to me: ? print (int) 0xA + 0; // prints 0 print (int) (0xA + 0); // prints 10 ? I think it's reasonable to expect those expressions to return the same value. Hmm, this is definitely interesting. The result of the second expression should be 0 too. I haven't had time to check why this happens as all conversions in zend_operators.c are with base 10. I vaguely remember someone changing something in this area a while ago. BTW in PHP 4.0.4 this prints out 1 (the second expression) which doesn't make much sense. The reason for this is that is_numeric_string() which is used in add_function() does convert hexadecimals whereas all other code in zend_operators.c doesn't. This is a pretty bad inconsistency which should be addressed. And I like to see it addresses so that above examples both print 10. Derick -- - Derick Rethans http://derickrethans.nl/ JDI Media Solutions http://www.jdimedia.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch
At 07:27 27/11/2002, Andi Gutmans wrote: At 04:41 PM 11/26/2002 -0500, Daniel Cowgill wrote: So why do the conversion in arithmetic? This seems bizarrely inconsistent to me: ? print (int) 0xA + 0; // prints 0 print (int) (0xA + 0); // prints 10 ? I think it's reasonable to expect those expressions to return the same value. Hmm, this is definitely interesting. The result of the second expression should be 0 too. I haven't had time to check why this happens as all conversions in zend_operators.c are with base 10. I vaguely remember someone changing something in this area a while ago. BTW in PHP 4.0.4 this prints out 1 (the second expression) which doesn't make much sense. The reason for this is that is_numeric_string() which is used in add_function() does convert hexadecimals whereas all other code in zend_operators.c doesn't. This is a pretty bad inconsistency which should be addressed. I think that the patch is ok. I think you might be mixing it with the overloading that I implemented for objects a while ago, which was a bad idea. Here - we're already converting the string to a number. If it doesn't 'look like a number', we end up having it at 0, which is the useless default. Getting it to work with a few extra cases doesn't hurt us in any way that I can tell. Standard disclaimers apply - I might be missing something. Zeev -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Error Codes, Langs, etc
At 02:27 27/11/2002, Stig S. Bakken wrote: Let's try being realistic, and focus on the quick wins first, such as good error codes. Go Stig. Zeev -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Concrete suggestion re: i18n messages
nope, it needs to be ini_set() -able if we're doing this at all .. either that or we keep English as the hard-coded default and trust that production server admins will see the wisdom of that. I don't get why we can't use an error code and spawn an i8n-friendly docref through it? - Original Message - From: Sascha Schumann [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 26, 2002 11:21 AM Subject: [PHP-DEV] Concrete suggestion re: i18n messages A possible implementation would look like this: A new ini setting is added. php.error_lang A new function is provided. php_error_ex(int type, const char *err_code, const char *fmt, ...); The function tries to lookup the err_code key in php-php.error_lang.cat. If it exists, the value will be used instead of the format fmt. The control is then passed to php_verror(). That sounds like 30-50 additional LOC to me. No bloat in sight. The program which generates the .cat files (gen-cat) will ensure that the error code is prepended to the format message. That could be a simple C file with another 50 LOC, parsing input files of the form file: file line | line line: ERROR-CODE MSG Each extension can maintain its own file (e.g. cat.session.nl for the NL version of the session error messages). During .cat build-time, a single per-language file is generated and fed through gen-cat. The result can then be used by PHP. There, simple and straight-forward. - Sascha -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Weird PHP Problem
Ok...Using newest version of PHP on an NT IIS machine with a SQL 2000 database. Here is the issue: I have a nvarchar field with a size of 4000. I submit a text string from a form to this field. It will display on submit using echo nl2br($variable) and it will display fine. When I look in the database, it has all the information stored correctly. When I pull it back out of the database, it cuts it off and only displays the first part of the string. Anyone have any ideas why? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP 5 - when?
Hi, First of all - I hope I post to the right group. I could not find any righter group for my question Can somebody tell me when the version 5 of PHP will be released? Can I find such plans at some website? Like: We plan to release version 4.3 in march, and then the version 5 about may ? I ask about it because I am not always up-to-date with PHP development. I am an editor of a polish software magazine, and I plan to make an issue dedicated to PHP_5 when it is released. Thanks for information - in advance -- Pozdrawiam, Piotr Sobolewski, wydawnictwo Software [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP 5 - when?
Hi Piotr, The short answer is that it will be ready when it is ready :) We don't have a definite time frame for PHP 5 (we are not 100% sure what features it will contain), and probably won't have a definite time frame until we begin the release cycle (typically a month or more before we release the code). At the moment we are doing QA on the PHP 4.3 release, with RC2 due this week. If you want a better idea of the ETA of 4.3, Andrei should have the answers (he is coordinating this release). The best way to stay up to date is to monitor this list; if you are short on time, you can find a weekly summary of this list on zend.com (in the developer zone). Hope that helps, --Wez. On 27 Nov 2002, Piotr Sobolewski wrote: Hi, First of all - I hope I post to the right group. I could not find any righter group for my question Can somebody tell me when the version 5 of PHP will be released? Can I find such plans at some website? Like: We plan to release version 4.3 in march, and then the version 5 about may ? I ask about it because I am not always up-to-date with PHP development. I am an editor of a polish software magazine, and I plan to make an issue dedicated to PHP_5 when it is released. Thanks for information - in advance -- Pozdrawiam, Piotr Sobolewski, wydawnictwo Software [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Weird PHP Problem
Yep, NVARCHAR's get pissy at large sizes (in my experience anyway) when PHP is interacting with them, (or any of the N variables for that matter) change it to a TEXT and see what happens. On Wed, 2002-11-27 at 06:20, Becky Gruebmeyer wrote: Ok...Using newest version of PHP on an NT IIS machine with a SQL 2000 database. Here is the issue: I have a nvarchar field with a size of 4000. I submit a text string from a form to this field. It will display on submit using echo nl2br($variable) and it will display fine. When I look in the database, it has all the information stored correctly. When I pull it back out of the database, it cuts it off and only displays the first part of the string. Anyone have any ideas why? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc signature.asc Description: This is a digitally signed message part
[PHP-DEV] call_stack
Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). If it's already implemented, i'm sorry, i could not be able to find it in the doc.. In this case RTFM is ok. Thanks, Miham KEREKES. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
On Wed, 27 Nov 2002 15:41:25 +0100 (CET) Derick Rethans [EMAIL PROTECTED] wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. Derick I thought debug_backtrace() was a ze2 thing. Does that mean 4.3 is going to use ze2? Phil Dier -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
debug_backtrace was backported into ze1. 4.3 will sstill use ze1. George Phil Dier wrote: On Wed, 27 Nov 2002 15:41:25 +0100 (CET) Derick Rethans [EMAIL PROTECTED] wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. Derick I thought debug_backtrace() was a ze2 thing. Does that mean 4.3 is going to use ze2? Phil Dier -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
On Wed, 27 Nov 2002 15:41:25 +0100 (CET) Derick Rethans [EMAIL PROTECTED] wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. Derick I thought debug_backtrace() was a ze2 thing. Does that mean 4.3 is going to use ze2? it has been backported... -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] my own superglobals?
Hi Gurus Is there any way to make my own variables supeglobal like $_GET, $_POST, ... ? I don't like $GLOBALS and I don't want to write the 'global' keyword each time I use my global variable in functions, I want to have a method to make it superglobal by default. 'Superglobal' means that it is available in all scopes throughout a script. I suggest following syntax: ?php // will declare superglobal variables global $mySuperglobalVariable = Hello; // make it superglobal global $_FORM = array_merge($_GET, $_POST); // yet another superglobal function test() { echo($mySuperglobalVariable); print_r($_FORM); // don't need global $mySuperglobalVariable // don't need $GLOBALS['mySuperglobalVariable '] } ? I hope it isn't a stupid idea, thaks -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] my own superglobals?
Hi, this was asked on this list at least once. The answer is no because the design of the language is this. If the user is given the chance to make variables superglobals than in my opinion big mess will come up. It is a mess even with coding by using global statement and global vars. Andrey - Original Message - From: Alexander Radivanovich [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 1:06 PM Subject: [PHP-DEV] my own superglobals? Hi Gurus Is there any way to make my own variables supeglobal like $_GET, $_POST, ... ? I don't like $GLOBALS and I don't want to write the 'global' keyword each time I use my global variable in functions, I want to have a method to make it superglobal by default. 'Superglobal' means that it is available in all scopes throughout a script. I suggest following syntax: ?php // will declare superglobal variables global $mySuperglobalVariable = Hello; // make it superglobal global $_FORM = array_merge($_GET, $_POST); // yet another superglobal function test() { echo($mySuperglobalVariable); print_r($_FORM); // don't need global $mySuperglobalVariable // don't need $GLOBALS['mySuperglobalVariable '] } ? I hope it isn't a stupid idea, thaks -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] my own superglobals?
Hi, No, this mechanism is only meant for the special variables (see archives of php-dev). In any case, I suggest you do use $GLOBALS[] and not the 'global' keyword because it works better and the recommended way. Andi At 01:06 PM 11/27/2002 +0200, Alexander Radivanovich wrote: Hi Gurus Is there any way to make my own variables supeglobal like $_GET, $_POST, ... ? I don't like $GLOBALS and I don't want to write the 'global' keyword each time I use my global variable in functions, I want to have a method to make it superglobal by default. 'Superglobal' means that it is available in all scopes throughout a script. I suggest following syntax: ?php // will declare superglobal variables global $mySuperglobalVariable = Hello; // make it superglobal global $_FORM = array_merge($_GET, $_POST); // yet another superglobal function test() { echo($mySuperglobalVariable); print_r($_FORM); // don't need global $mySuperglobalVariable // don't need $GLOBALS['mySuperglobalVariable '] } ? I hope it isn't a stupid idea, thaks -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Bug #20460 (Feature Request)
User complains that maximum length of a line used by fscanf is too short (he has lines 1600 chars). Looking at file.h I agree (it's only 512). The user requested two options: 1) Add an optional length field. No way to do that without breaking parameter list. :( 2) Increase to a larger arbitrary number. This simply has the problem that it may prove too short eventually as well. Plus I came up with a third option: 3) Create an .ini entry to specify the maximum length used. I think this has the best overall return on it. If #3 sounds okay I'll get to work on it. I await your comments. -Pollita -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
On Wed, 27 Nov 2002, Sara Pollita Golemon wrote: User complains that maximum length of a line used by fscanf is too short (he has lines 1600 chars). Looking at file.h I agree (it's only 512). The user requested two options: 1) Add an optional length field. No way to do that without breaking parameter list. :( We can't really do that, users will get pissed :) 2) Increase to a larger arbitrary number. This simply has the problem that it may prove too short eventually as well. Yeah, IMO it doesn't solve anything. Plus I came up with a third option: 3) Create an .ini entry to specify the maximum length used. I think this has the best overall return on it. I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
User complains that maximum length of a line used by fscanf is too short (he has lines 1600 chars). Looking at file.h I agree (it's only 512). The user requested two options: 1) Add an optional length field. No way to do that without breaking parameter list. :( 2) Increase to a larger arbitrary number. This simply has the problem that it may prove too short eventually as well. Plus I came up with a third option: 3) Create an .ini entry to specify the maximum length used. I think this has the best overall return on it. The thing is that just feels kinda dirty (an ini option controlling how long a line should be assumed for fscanf, but I agree there is no really good solution), unless of course it means changing the parameter order to fscanf(). -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. Andi In case anyone's interested, here's what I use for my custom error handler: function __debug_error_handler($type, $msg, $file, $line, $context) { if (ini_get('html_errors')) { $hr = 'HR'; $br = 'BR'; $nbsp = 'nbsp;'; $b = 'B'; $slash_b = '/B'; } else { $hr = ---\n; $br = ''; $nbsp = ' '; $b = ''; $slash_b = ''; } echo $hr . ini_get('error_prepend_string'); $list = Array(E_USER_ERROR = 'U_ERROR', E_USER_WARNING = 'U_WARNING', E_USER_NOTICE = 'U_NOTICE', E_ERROR = 'ERROR', E_WARNING = 'WARNING', E_NOTICE = 'NOTICE'); if (array_key_exists($type, $list)) { $type = $list[$type]; } else { $type = UNKNOWN ERROR CODE ($type); } echo $b$type:$slash_b $msg$br\n; $bt = debug_backtrace(); $from = ''; for ($i = 1; $i count($bt); ++$i) { $step = $bt[$i]; $class = isset($step['class']) ? $step['class'] . '::' : ''; if (empty($step['file'])) $step['file'] = ''; if (empty($step['line'])) $step['line'] = ''; printf($nbsp$nbsp %s$b%s%s$slash_b [%s:%s]$br\n, $from, $class, $step['function'], $step['file'], $step['line'] ); $from = $nbsp$nbsp$nbsp$nbsp from ; } echo ini_get('error_append_string'); } // __debug_error_handler -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Well, probably the following: class::function() called at file:line with arguments: nice_serialize(args) where nice_serialize() do almost the same as serialize, but the result were _more_ human readable This solution would give shorter trace. But - it's only my opinion :-) M. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: Weird PHP Problem
Try Looking at this parameter in the php.ini: ; Valid range 0 - 2147483647. Default = 4096. mssql.textlimit = 65536 ; Valid range 0 - 2147483647. Default = 4096. mssql.textsize = 65536 colin Becky Gruebmeyer [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok...Using newest version of PHP on an NT IIS machine with a SQL 2000 database. Here is the issue: I have a nvarchar field with a size of 4000. I submit a text string from a form to this field. It will display on submit using echo nl2br($variable) and it will display fine. When I look in the database, it has all the information stored correctly. When I pull it back out of the database, it cuts it off and only displays the first part of the string. Anyone have any ideas why? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
Hmmm any hints on how to get the variable name out of the stack? The code in debug_backtrace seems to only extract the value. George Andi Gutmans wrote: I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote: Hmmm any hints on how to get the variable name out of the stack? The code in debug_backtrace seems to only extract the value. There's no way but I don't think it's needed. When I wrote $arg1 I meant the value not the name of the variable. Sorry if I wasn't clear. Andi George Andi Gutmans wrote: I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
Ok... but that looks nasty when you are passed an array or an object. Andi Gutmans wrote: At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote: Hmmm any hints on how to get the variable name out of the stack? The code in debug_backtrace seems to only extract the value. There's no way but I don't think it's needed. When I wrote $arg1 I meant the value not the name of the variable. Sorry if I wasn't clear. Andi George Andi Gutmans wrote: I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
Derick Rethans [EMAIL PROTECTED] wrote: On Wed, 27 Nov 2002, Sara Pollita Golemon wrote: User complains that maximum length of a line used by fscanf is too short (he has lines 1600 chars). Looking at file.h I agree (it's only 512). The user requested two options: 1) Add an optional length field. No way to do that without breaking parameter list. :( We can't really do that, users will get pissed :) 2) Increase to a larger arbitrary number. This simply has the problem that it may prove too short eventually as well. Yeah, IMO it doesn't solve anything. Plus I came up with a third option: 3) Create an .ini entry to specify the maximum length used. I think this has the best overall return on it. I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I like this fourth option, because the internal scanf function will anyway need reimplementation since it's not binary safe. Moriyoshi Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I like this fourth option, because the internal scanf function will anyway need reimplementation since it's not binary safe. err. it didn't need a reimplementation, i fixed it, it works fine in cvs. -Sterling Moriyoshi Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
On Thu, 28 Nov 2002, Moriyoshi Koizumi wrote: Derick Rethans [EMAIL PROTECTED] wrote: I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I like this fourth option, because the internal scanf function will anyway need reimplementation since it's not binary safe. Sterling just implemented that. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
err. it didn't need a reimplementation, i fixed it, it works fine in cvs. Then, ?php $buf = 123 456 \0 567 sscanf($buf, %d%d%s%d, $a, $b, $c, $d); var_dump($a, $b, $c, $d); ? How about this? The result was the same as for fscanf. Moriyoshi -Sterling Moriyoshi Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 03:18 PM 11/27/2002 -0500, George Schlossnagle wrote: Ok... but that looks nasty when you are passed an array or an object. Yeah but backtraces tend to look nasty :) Andi Andi Gutmans wrote: At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote: Hmmm any hints on how to get the variable name out of the stack? The code in debug_backtrace seems to only extract the value. There's no way but I don't think it's needed. When I wrote $arg1 I meant the value not the name of the variable. Sorry if I wasn't clear. Andi George Andi Gutmans wrote: I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
err. it didn't need a reimplementation, i fixed it, it works fine in cvs. Then, ?php $buf = 123 456 \0 567 sscanf($buf, %d%d%s%d, $a, $b, $c, $d); var_dump($a, $b, $c, $d); ? How about this? The result was the same as for fscanf. Yes, but it didn't need a reimplementation as far as using arbitrary buffer sizes. -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
Sterling Hughes [EMAIL PROTECTED] wrote: err. it didn't need a reimplementation, i fixed it, it works fine in cvs. Then, ?php $buf = 123 456 \0 567 sscanf($buf, %d%d%s%d, $a, $b, $c, $d); var_dump($a, $b, $c, $d); ? How about this? The result was the same as for fscanf. Yes, but it didn't need a reimplementation as far as using arbitrary buffer sizes. Right, I just missed a big point about the scanf behaviour :) Moriyoshi -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
Derick Rethans [EMAIL PROTECTED] wrote: I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I'll admit to not knowing what you mean by 'dynamically sized buffer's. Is there an example of another function which works with such? -Pollita -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
Derick Rethans [EMAIL PROTECTED] wrote: I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I'll admit to not knowing what you mean by 'dynamically sized buffer's. Is there an example of another function which works with such? a php function, not sure, spprintf() is a perfect example though (in C). Basically, a dynamically sized buffer is a buffer that grows or shrinks when necessary (dynamically :) Anyhow, I've got fscanf() doing what you wanted in CVS (as well as the release branch), give it a try, and see if it meets your needs. -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20460 (Feature Request)
On Wed, 27 Nov 2002, Sara Pollita Golemon wrote: Derick Rethans [EMAIL PROTECTED] wrote: I don't like us adding a new ini entry for this, I think we should try another option: 4) Make sure we can use fscanf on a dynamically sized buffer. This will definitely the hardest solution, but also the most beautiful one. I'll admit to not knowing what you mean by 'dynamically sized buffer's. Is there an example of another function which works with such? char *buf; buf = malloc(length of line); vs. char buf[MAX_BUF_SIZE]; and example of such a function is AFAIK not really available for a PHP function, but api wise there is php_stream_get_line which uses it. As you can see sterling just put that in to 'fix' this feature report (his commit to file.c). regards, Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Bug #20308 (Feature Request)
While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. Index: url.c === RCS file: /repository/php4/ext/standard/url.c,v retrieving revision 1.59 diff -u -r1.59 url.c --- url.c 14 Nov 2002 13:40:14 - 1.59 +++ url.c 27 Nov 2002 20:44:25 - @@ -267,6 +267,26 @@ php_replace_controlchars(ret-path); } + if (strcmp(ret-scheme,mailto) == 0) { + s = estrndup(ret-path, strlen(ret-path)); + ue = s + strlen(ret-path); + p = s + 1; + /* a mailto starting with @ would be malformed, but let's keep it +clean */ + if (s[0] == '@') { + s[0] = '\0'; + } + /* scan for @ to separate user from host */ + while (p ue p[-1] != '\0') { + if (p[0] == '@') { + p[0] = '\0'; + } + p++; + } + ret-user = s; + /* the free() process in php_url_free will segfault if we don't duplicate this string value */ + ret-host = estrndup(p, (ue-p)); + } + return ret; } /* }}} */ Index: url.c === RCS file: /repository/php4/ext/standard/url.c,v retrieving revision 1.59 diff -u -r1.59 url.c --- url.c 14 Nov 2002 13:40:14 - 1.59 +++ url.c 27 Nov 2002 20:44:25 - @@ -267,6 +267,26 @@ php_replace_controlchars(ret-path); } + if (strcmp(ret-scheme,mailto) == 0) { + s = estrndup(ret-path, strlen(ret-path)); + ue = s + strlen(ret-path); + p = s + 1; + /* a mailto starting with @ would be malformed, but let's keep it +clean */ + if (s[0] == '@') { + s[0] = '\0'; + } + /* scan for @ to separate user from host */ + while (p ue p[-1] != '\0') { + if (p[0] == '@') { + p[0] = '\0'; + } + p++; + } + ret-user = s; + /* the free() process in php_url_free will segfault if we don't +duplicate this string value */ + ret-host = estrndup(p, (ue-p)); + } + return ret; } /* }}} */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. I like the idea, just 2 little things with the patch... Index: url.c === RCS file: /repository/php4/ext/standard/url.c,v retrieving revision 1.59 diff -u -r1.59 url.c --- url.c 14 Nov 2002 13:40:14 - 1.59 +++ url.c 27 Nov 2002 20:44:25 - @@ -267,6 +267,26 @@ php_replace_controlchars(ret-path); } + if (strcmp(ret-scheme,mailto) == 0) { + s = estrndup(ret-path, strlen(ret-path)); + ue = s + strlen(ret-path); why not cache this strlen() and not double calculate it. + p = s + 1; + /* a mailto starting with @ would be malformed, but let's keep it clean */ + if (s[0] == '@') { + s[0] = '\0'; + } + /* scan for @ to separate user from host */ + while (p ue p[-1] != '\0') { + if (p[0] == '@') { + p[0] = '\0'; + } + p++; + } why not use strchr() or memchr() for this code? -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
I am not so sure that adding special cases for things like mailto: and so on is a good idea. The code works identically to how it worked in 4.2.3 and prior. Ilia On November 27, 2002 04:19 pm, Sara Pollita Golemon wrote: While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. Index: url.c === RCS file: /repository/php4/ext/standard/url.c,v retrieving revision 1.59 diff -u -r1.59 url.c --- url.c 14 Nov 2002 13:40:14 - 1.59 +++ url.c 27 Nov 2002 20:44:25 - @@ -267,6 +267,26 @@ php_replace_controlchars(ret-path); } + if (strcmp(ret-scheme,mailto) == 0) { + s = estrndup(ret-path, strlen(ret-path)); + ue = s + strlen(ret-path); + p = s + 1; + /* a mailto starting with @ would be malformed, but let's keep it clean */ + if (s[0] == '@') { + s[0] = '\0'; + } + /* scan for @ to separate user from host */ + while (p ue p[-1] != '\0') { + if (p[0] == '@') { + p[0] = '\0'; + } + p++; + } + ret-user = s; + /* the free() process in php_url_free will segfault if we don't duplicate this string value */ + ret-host = estrndup(p, (ue-p)); + } + return ret; } /* }}} */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP urlencode() - JAVA
Hi I nedd to know, what command matches best with urlencode() from PHP. Is it encodeURL() or encodeRedirectURL() or something else. thx for your help mfg Robert -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
That was one of the comments I was looking for Is this really necessary? After all the user can certainly use explode() to take it apart. I'm not against giving him that answer, it was just a quick patch to write... Is that a -1 then? I am not so sure that adding special cases for things like mailto: and so on is a good idea. The code works identically to how it worked in 4.2.3 and prior. Ilia On November 27, 2002 04:19 pm, Sara Pollita Golemon wrote: While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I quite like the output of foreach ($backtrace as $step) { if (!empty($step['args'])) { foreach ($step['args'] as $arg) { $args = isset($args) ? $args . ', ' : ''; $args .= var_export($arg, true); } } else { $args = ''; } $args = str_replace(array(\n, ',)'), array('', ')'), $args); printf( %s%s(%s) [%s:%s]\n, isset($step['class']) ? $step['class'] . '::' : '', $step['function'], $args, $step['file'], $step['line'] ); } -- Sebastian Bergmann http://sebastian-bergmann.de/ http://phpOpenTracker.de/ Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
On November 27, 2002 04:45 pm, Sara Pollita Golemon wrote: That was one of the comments I was looking for Is this really necessary? After all the user can certainly use explode() to take it apart. I'm not against giving him that answer, it was just a quick patch to write... Is that a -1 then? Yup, -1 from me. I am not so sure that adding special cases for things like mailto: and so on is a good idea. The code works identically to how it worked in 4.2.3 and prior. Ilia On November 27, 2002 04:19 pm, Sara Pollita Golemon wrote: While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
On November 27, 2002 04:45 pm, Sara Pollita Golemon wrote: That was one of the comments I was looking for Is this really necessary? After all the user can certainly use explode() to take it apart. I'm not against giving him that answer, it was just a quick patch to write... Is that a -1 then? Yup, -1 from me. I disagree with this, the current behaviour is imho wrong. mailto: is a url, rejecting the patch because it introduces a special case, is not a good thing. parse_url() is for _all_ url's, not just http:// url's, and besides, the current syntax for mailto is completely valid, and should be parsed anyway. (ie, a special case shouldn't be required if the url parser was rfc compliant). -Sterling I am not so sure that adding special cases for things like mailto: and so on is a good idea. The code works identically to how it worked in 4.2.3 and prior. Ilia On November 27, 2002 04:19 pm, Sara Pollita Golemon wrote: While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Parse search string a la Google (Regular expression?)
Hi, In my application I would like to offer a search interface like Google and other popular search engines. The complication for me is to explode the search string into proper array elements, like this: $search_str = \search for this sentence\ -NotForThisWord ButDefinitelyForThisWord; $array[0]: search for this sentence $array[1]: -NotForThisWord $array[2]: ButDefinitelyForThisWord I have tried to use regular expressions but my case seems to be a bit more complicated for this (?). Does anybody have a code snippet, a class or something, that can help me with this? Thanks in advance, Joachim -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Bug #20308 (Feature Request)
On November 27, 2002 04:32 pm, Sterling Hughes wrote: On November 27, 2002 04:45 pm, Sara Pollita Golemon wrote: That was one of the comments I was looking for Is this really necessary? After all the user can certainly use explode() to take it apart. I'm not against giving him that answer, it was just a quick patch to write... Is that a -1 then? Yup, -1 from me. I disagree with this, the current behaviour is imho wrong. mailto: is a url, rejecting the patch because it introduces a special case, is not a good thing. parse_url() is for _all_ url's, not just http:// url's, and besides, the current syntax for mailto is completely valid, and should be parsed anyway. (ie, a special case shouldn't be required if the url parser was rfc compliant). PHP's php_url_parse() function is not in any way limited to http:// as you claim, it support a large variety of valid URLs, take a look at the very extensive test for parse_url() function located here: ext/standard/tests/strings/url_t.phpt. Even the regular expression described in RFC 2396 does not recognize mailto: any differently the our very own parse_url(). Ilia -Sterling I am not so sure that adding special cases for things like mailto: and so on is a good idea. The code works identically to how it worked in 4.2.3 and prior. Ilia On November 27, 2002 04:19 pm, Sara Pollita Golemon wrote: While waiting for opinions on Bug#20460 I went ahead and addressed #20308. User complains that parse_url returns the full email address in 'path' element. Makes reference to documents which claim it should return 'user' and 'host' element. To address this request and maintain backward compatability I wrote a patch to split the 'path' element in to 'host' and 'user' elements then return all three. Ex: *current behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] } *new behavior* print_r(parse_url(mailto:[EMAIL PROTECTED];)); Array ( [scheme] = mailto [path] = [EMAIL PROTECTED] [user] = pollita [host] = php.net } If there are no objections I'll commit this change. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
Here's first shot at a patch. The output it generates is ugly as sin if you use objects though. I though about flattening them out, but that gets long and nasty (and requires specialized print functions which while easy seem to be of marginal use elsewhere.) George Index: Zend/zend_builtin_functions.c === RCS file: /repository/Zend/zend_builtin_functions.c,v retrieving revision 1.127 diff -u -3 -r1.127 zend_builtin_functions.c --- Zend/zend_builtin_functions.c 27 Nov 2002 20:11:39 - 1.127 +++ Zend/zend_builtin_functions.c 27 Nov 2002 22:42:57 - @@ -68,6 +68,7 @@ static ZEND_FUNCTION(get_extension_funcs); static ZEND_FUNCTION(get_defined_constants); static ZEND_FUNCTION(debug_backtrace); +static ZEND_FUNCTION(debug_print_backtrace); #if ZEND_DEBUG static ZEND_FUNCTION(zend_test_func); #endif @@ -122,6 +123,7 @@ ZEND_FE(get_extension_funcs,NULL) ZEND_FE(get_defined_constants, NULL) ZEND_FE(debug_backtrace,NULL) + ZEND_FE(debug_print_backtrace, NULL) #if ZEND_DEBUG ZEND_FE(zend_test_func, NULL) #endif @@ -1171,6 +1173,151 @@ add_next_index_zval(arg_array, *arg); } return arg_array; +} + + +void debug_print_backtrace_args(zval *arg_array) +{ +zval **tmp; +HashPosition iterator; +int i = 0; + +zend_hash_internal_pointer_reset_ex(arg_array-value.ht, iterator); +while (zend_hash_get_current_data_ex(arg_array-value.ht, (void **) tmp, +iterator) == SUCCESS) { + if(i++) { + ZEND_PUTS(,); + } + zend_print_zval_r(*tmp, 4); + zend_hash_move_forward_ex(arg_array-value.ht, iterator); +} +} + +/* {{{ proto void debug_backtrace(void) + Prints out a backtrace */ +ZEND_FUNCTION(debug_print_backtrace) +{ + zend_execute_data *ptr; + int lineno; + char *function_name; + char *filename; + char *class_name; + char *call_type; + char *include_filename = NULL; + zval *stack_frame; + zval *arg_array; + void **cur_arg_pos = EG(argument_stack).top_element; + void **args = cur_arg_pos; + int arg_stack_consistent = 0; + int frames_on_stack = 0; + int indent = 0; + int i; + + if (ZEND_NUM_ARGS()) { + ZEND_WRONG_PARAM_COUNT(); + } + + while (--args = EG(argument_stack).elements) { + if (*args--) { + break; + } + args -= *(ulong*)args; + frames_on_stack++; + + if (args == EG(argument_stack).elements) { + arg_stack_consistent = 1; + break; + } + } + + ptr = EG(current_execute_data); + + /* skip debug_backtrace() */ + ptr = ptr-prev_execute_data; + cur_arg_pos -= 2; + frames_on_stack--; + + array_init(return_value); + + while (ptr) { + if (ptr-op_array) { + filename = ptr-op_array-filename; + lineno = ptr-opline-lineno; + } else { + filename = NULL; + } + + function_name = ptr-function_state.function-common.function_name; + + if (function_name) { + if (ptr-ce) { + class_name = ptr-ce-name; + call_type = ::; + } else if (ptr-object.ptr) { + class_name = ptr-object.ptr-value.obj.ce-name; + call_type = -; + } else { + class_name = NULL; + call_type = NULL; + } + if ((! ptr-opline) || ((ptr-opline-opcode == +ZEND_DO_FCALL_BY_NAME) || (ptr-opline-opcode == ZEND_DO_FCALL))) { + if (arg_stack_consistent (frames_on_stack 0)) { + arg_array = +debug_backtrace_get_args(cur_arg_pos TSRMLS_CC); + frames_on_stack--; + } + } + } else { + /* i know this is kinda ugly, but i'm trying to avoid extra +cycles in the main execution loop */ + zend_bool build_filename_arg = 1; + + switch (ptr-opline-op2.u.constant.value.lval) { + case ZEND_EVAL: + function_name = eval; + build_filename_arg = 0; + break; + case ZEND_INCLUDE: + function_name = include; +
Re: [PHP-DEV] call_stack
And here is a version which flattens the calling args onto a single line (similar to sebastians usersapce script). Longer, but a bit prettier output. Index: Zend/zend.c === RCS file: /repository/Zend/zend.c,v retrieving revision 1.163 diff -u -3 -r1.163 zend.c --- Zend/zend.c 17 Nov 2002 13:26:36 - 1.163 +++ Zend/zend.c 27 Nov 2002 23:07:00 - @@ -138,6 +138,35 @@ } +static void print_flat_hash(HashTable *ht) +{ + zval **tmp; + char *string_key; + HashPosition iterator; + ulong num_key; + uint str_len; + int i = 0; + + zend_hash_internal_pointer_reset_ex(ht, iterator); + while (zend_hash_get_current_data_ex(ht, (void **) tmp, iterator) == +SUCCESS) { + if(i++ 0) { + ZEND_PUTS(,); + } + ZEND_PUTS([); + switch (zend_hash_get_current_key_ex(ht, string_key, str_len, +num_key, 0, iterator)) { + case HASH_KEY_IS_STRING: + ZEND_PUTS(string_key); + break; + case HASH_KEY_IS_LONG: + zend_printf(%ld, num_key); + break; + } + ZEND_PUTS(] = ); + zend_print_flat_zval_r(*tmp); + zend_hash_move_forward_ex(ht, iterator); + } +} + ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy) { if (expr-type==IS_STRING) { @@ -215,6 +244,43 @@ } +ZEND_API void zend_print_flat_zval_r(zval *expr) +{ + zend_write_func_t write_func = zend_write; + + switch(expr-type) { + case IS_ARRAY: + ZEND_PUTS(Array (); + if (++expr-value.ht-nApplyCount1) { + ZEND_PUTS( *RECURSION*); + expr-value.ht-nApplyCount--; + return; + } + print_flat_hash(expr-value.ht); + ZEND_PUTS()); + expr-value.ht-nApplyCount--; + break; + case IS_OBJECT: + { + zend_object *object = Z_OBJ_P(expr); + + if (++object-properties-nApplyCount1) { + ZEND_PUTS( *RECURSION*); + object-properties-nApplyCount--; + return; + } + zend_printf(%s Object (, object-ce-name); + print_flat_hash(object-properties); + ZEND_PUTS()); + object-properties-nApplyCount--; + break; + } + default: + zend_print_variable(expr); + break; + } +} + ZEND_API void zend_print_zval_r(zval *expr, int indent) { zend_print_zval_r_ex(zend_write, expr, indent); @@ -253,6 +319,7 @@ break; } } + static FILE *zend_fopen_wrapper(const char *filename, char **opened_path) Index: Zend/zend.h === RCS file: /repository/Zend/zend.h,v retrieving revision 1.166 diff -u -3 -r1.166 zend.h --- Zend/zend.h 17 Nov 2002 13:26:36 - 1.166 +++ Zend/zend.h 27 Nov 2002 23:07:00 - @@ -383,6 +383,7 @@ ZEND_API int zend_print_zval(zval *expr, int indent); ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent); ZEND_API void zend_print_zval_r(zval *expr, int indent); +ZEND_API void zend_print_flat_zval_r(zval *expr); ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent); ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...); Index: Zend/zend_builtin_functions.c === RCS file: /repository/Zend/zend_builtin_functions.c,v retrieving revision 1.127 diff -u -3 -r1.127 zend_builtin_functions.c --- Zend/zend_builtin_functions.c 27 Nov 2002 20:11:39 - 1.127 +++ Zend/zend_builtin_functions.c 27 Nov 2002 23:07:00 - @@ -68,6 +68,7 @@ static ZEND_FUNCTION(get_extension_funcs); static ZEND_FUNCTION(get_defined_constants); static ZEND_FUNCTION(debug_backtrace); +static ZEND_FUNCTION(debug_print_backtrace); #if ZEND_DEBUG static ZEND_FUNCTION(zend_test_func); #endif @@ -122,6 +123,7 @@ ZEND_FE(get_extension_funcs,NULL) ZEND_FE(get_defined_constants, NULL) ZEND_FE(debug_backtrace,NULL) + ZEND_FE(debug_print_backtrace, NULL) #if ZEND_DEBUG
[PHP-DEV] Reusing PHP string value pointers
Apologies in advance if this is the wrong mailing list. Please direct me to a more appropriate mailing list if there is one :-) When a PHP string variable is changed via a PHP script, such as: $foo = 'new value'; what happens to the `value.str.val' pointer internally? Is it possible to have the new value assigned to the same `value.str.val' pointer that the variable is currently using instead of having that pointer replaced by a pointer to the new value? I have an internal function that binds to a particular pointer address, from which it reads data at a later point. I'd like to allow the value at that address to be modified by assignment from within a PHP script. The following PHP pseudocode is a simple example of this concept: $foo = 'my value'; bind_value($foo); // a pointer to foo's value is stored internally. print_value(); // output 'my value', which is the current value of the pointer. $foo = 'a new value'; print_value(); // output 'a new value', which is the new value of the pointer. In other words, I need the new value copied to the same pointer address as the old value. I know that it's possible to retrieve the value of a variable via a hash/list lookup on the variable name, but the pointer is being passed to a function outside the scope of this module, and that function expects it to just work with a pre-designated string pointer. Any suggestions and/or clarification would be greatly appreciated. Thanks, Marshall -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Parse search string a la Google (Regular expression?)
Benny Rasmussen wrote: Hi, In my application I would like to offer a search interface like Google and other popular search engines. The complication for me is to explode the search string into proper array elements, like this: $search_str = \search for this sentence\ -NotForThisWord ButDefinitelyForThisWord; $array[0]: search for this sentence $array[1]: -NotForThisWord $array[2]: ButDefinitelyForThisWord I have tried to use regular expressions but my case seems to be a bit more complicated for this (?). Does anybody have a code snippet, a class or something, that can help me with this? Thanks in advance, Joachim -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php Forwarding to [EMAIL PROTECTED], since this would be the appropriate list for the topic. [EMAIL PROTECTED] is for the development *of* PHP itself, not for developing *with* PHP. -- Sebastian Bergmann http://sebastian-bergmann.de/ http://phpOpenTracker.de/ Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP 4.3.0RC2 released
The second release candidate of the inimitably fabulous PHP version 4.3.0 is out. It can be downloaded from http://qa.php.net. Give it a good testing! -Andrei -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP Memory Error
Could someone please help. Running Linux 7.3 RH with 512 MB Ram with Apache and PHP 4. I receive the following error and was wondering if anyone had any suggestions. The error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /var/www/html/vc/test_fort/bootstrap.php on line 267. Is there a server setting eliminating the ability to allocate more memory. Any suggestions would be helpful. You can reply to [EMAIL PROTECTED] as well. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP Memory Error
in your php.ini file you have allocated only 8mb for use... this is probably not sufficient for your scripts to use... remember that this size is in bytes... you might want something like this... 67108860 bytes = 64 mb Jonathan Williams [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Could someone please help. Running Linux 7.3 RH with 512 MB Ram with Apache and PHP 4. I receive the following error and was wondering if anyone had any suggestions. The error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /var/www/html/vc/test_fort/bootstrap.php on line 267. Is there a server setting eliminating the ability to allocate more memory. Any suggestions would be helpful. You can reply to [EMAIL PROTECTED] as well. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] PHP Memory Error
67108860 bytes = 64 mb 64M will also work, I believe. John Jonathan Williams [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Could someone please help. Running Linux 7.3 RH with 512 MB Ram with Apache and PHP 4. I receive the following error and was wondering if anyone had any suggestions. The error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /var/www/html/vc/test_fort/bootstrap.php on line 267. Is there a server setting eliminating the ability to allocate more memory. Any suggestions would be helpful. You can reply to [EMAIL PROTECTED] as well. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] PHP Memory Error
I started a faq on this but anyway one can use K (kilobytes) or M (megabytes) for these type of directives. A plain integer == Bytes. Regards, Philip On Wed, 27 Nov 2002, John Coggeshall wrote: 67108860 bytes = 64 mb 64M will also work, I believe. John Jonathan Williams [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Could someone please help. Running Linux 7.3 RH with 512 MB Ram with Apache and PHP 4. I receive the following error and was wondering if anyone had any suggestions. The error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /var/www/html/vc/test_fort/bootstrap.php on line 267. Is there a server setting eliminating the ability to allocate more memory. Any suggestions would be helpful. You can reply to [EMAIL PROTECTED] as well. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php