Re: [PHP-DEV] While-else
It can save you one if-statement, where the condition would be identical to the where condition. Example: if ($i = 10) { while ($i = 10) { $i++; } } else { echo $i is more than 10\n; } I personally hate overspecifications, and this is one situation where that's the case. So actually, I would like while-else support. Just my humble 2 futile cents of course. Regards, Ron Richard Lynch [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote: Is it possible to make a while with a else-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: - ? $i = 1; while ($i = 10) { echo $i++; } else { echo The while couldn't be executed!; } ? - So it executes after the last iteration? No. It must only execute if there were no iterations?... Maybe I'm just an old fart, but I don't like it... :-v -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] While-else
- Original Message - On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote: Is it possible to make a while with a else-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: - ? $i = 1; while ($i = 10) { echo $i++; } else { echo The while couldn't be executed!; } ? - I have wanted to use this kind of syntax a couple of times, for example: ?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ? Otherwise I would write the above code as a while + a if. However I'm unsure if this syntax should be put into PHP, but I thought I'll just post a example of when I would use it. thanks Andrew -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
php6 always handles all internal work in utf-8 But, from what I remember, there should be a way to specify encoding in which you expect data to arrive (in this example from mysql_*) I think, that someone who knows more will give you more details On 5/3/07, Rangel Reale [EMAIL PROTECTED] wrote: Hello! I am trying to understand how PHP6 handling of unicode works, I think I am missing something. My config is: ; Unicode settings ; unicode.semantics = on unicode.runtime_encoding = iso-8859-1 unicode.script_encoding = iso-8859-1 unicode.output_encoding = utf-8 unicode.from_error_mode = U_INVALID_SUBSTITUTE unicode.from_error_subst_char = 3f unicode.fallback_encoding = iso-8859-1 I use a mysql database, with iso-8859-1 (Portuguese - latin 1) text, with accented characters. What I was trying to understand was, because unicode.runtime_encoding = iso-8859-1, I tought that all internal operations were done in this encoding, and only when outputting (unicode.output_encoding = utf-8) data would be converted to utf-8. So to me, I did a mysql query with latin1, data comes to my variables as iso-8859-1, I use them, and only when I echo'ed them, they would become utf-8, from a iso-8859-1-to-utf-8-like function. But when I do query in any record that have accented characters I get this warning (using mysql_fetch_assoc): -- Could not convert binary string to Unicode string (converter UTF-8 failed on bytes (0xE7) at offset 9) -- for all accented characters in all fields. The strange thing to me, is the mysql_fetch_assoc function give this error even before I accessed the field values, as I understanded from the above explanation. If I changed the set names query to: mysql_query('set names utf8', $this-mysql_link); then it works, but I would like to understand how this works, to make my program the right way from the start. Did I misundertood something? Thanks, Rangel -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
On Thu, 3 May 2007, Alexey Zakhlestin wrote: php6 always handles all internal work in utf-8 No, it is UTF-16 internally. Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] How to find a bug: is_link troubles
On 5/2/07, Arnold Daniels [EMAIL PROTECTED] wrote: Hi, I've got a bug with is_link and lstats. Any symlinks not created in the current session, will not be read. This only occurs in the Apache 2 SAPI version, not in the CLI version. Script: ? $symlink = '/tmp/link-test'; if (file_exists($symlink)) unlink($symlink); symlink('/tmp/pear', $symlink); echo (file_exists($symlink) ? is_link($symlink) ? Correct : ERROR : Couldn't create the link), br/\n; $symlink = '/tmp/link-persist'; if (!file_exists($symlink)) symlink('/tmp/pear', $symlink); echo (file_exists($symlink) ? is_link($symlink) ? Correct : ERROR : Couldn't create the link), br/\n; ? First run: Correct Correct Second run: Correct ERROR Next runs: Correct ERROR I've recently start using the daily snapshots op PHP, but I also tried it on version 5.2.1, which shows the same result. It used to work just fine, so I'm sure this isn't the expected result. I've recently upgraded from Ubuntu Edgy (6.10) to Feisty (7.04), with kernel and apache update, so I believe that the problem is related to that. I've straced the process (see attachment), but I can't pinpoint the problem. This is a big issue for me, can anyone point me in the right direction to find the source of this problem. Thanks, Arnold snip Well, I've also tested this code, and it does work fine. BUT if /tmp/pear doesn't exists, what i had at first, then file_exists returns false, because file_exists follows symlinks, and the symlink pointed to nothing. So if you're sure that $symlink is a link, then it might be better to check it with is_link. Also, the is_link function is cached, so you might want to add one or more clearstatcache() in your script. I checked your strace also, but it doesn't look like there's a bug. But I've never studied on the PHP core so Well, if above doesn't help you, then one of the real experts needs to look at it :) Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Help with the snaps site
On 5/2/07, Edin Kadribasic [EMAIL PROTECTED] wrote: Jan Reininghaus wrote: I would like to suggest a redesign of the page. In my opinion the page is too complex, so for example I find it a bit hard to match the information for the next snapshots in the left of the page with the snapshots itself on the right. I find it also complex that the source and the win32 packages are separated and have its own creation intervals. In case there is no special reason for that I would suggest to distribute everything together. I have uploaded a design I could imagine to http://hp-film.pytalhost.de/test/php/snaps_draw.png. The page is a bit confusing and I didn't want too much new stuff to it without thinking about it first. Your suggestion is promising, but it might be a bit too wide for people that have smaller screen resolutions. I think we need to make it look good at 1024x768. Yes, it's very wide. So what about this: (Quick edit..) http://86.86.80.41/PHP/snaps_draw_edit.PNG There are some things you have missed. There are two different source bundles (gz and bz2). Next build depends on the system (source or bins) and the PHP version (we build some windows snapshots more often than others). By the way, I can't follow the link to the PHP installer because I get the error message that the access to the file is Forbidden. Thanks for the heads up. This should be fixed now. Would you be willing to produce the HTML needed for the redesign? Edin Else i will :) Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Help with the snaps site
How about something along these lines ... (Not pretty as I'm crap at the design - sorry). http://rquadling.php1h.com/snap.html Use icons for the labels (BZ2, GZ, ZIP, PECL, INST, COMP, SNAP). The logs for failed builds could also be included. Richard. On 03/05/07, Tijnema ! [EMAIL PROTECTED] wrote: On 5/2/07, Edin Kadribasic [EMAIL PROTECTED] wrote: Jan Reininghaus wrote: I would like to suggest a redesign of the page. In my opinion the page is too complex, so for example I find it a bit hard to match the information for the next snapshots in the left of the page with the snapshots itself on the right. I find it also complex that the source and the win32 packages are separated and have its own creation intervals. In case there is no special reason for that I would suggest to distribute everything together. I have uploaded a design I could imagine to http://hp-film.pytalhost.de/test/php/snaps_draw.png. The page is a bit confusing and I didn't want too much new stuff to it without thinking about it first. Your suggestion is promising, but it might be a bit too wide for people that have smaller screen resolutions. I think we need to make it look good at 1024x768. Yes, it's very wide. So what about this: (Quick edit..) http://86.86.80.41/PHP/snaps_draw_edit.PNG There are some things you have missed. There are two different source bundles (gz and bz2). Next build depends on the system (source or bins) and the PHP version (we build some windows snapshots more often than others). By the way, I can't follow the link to the PHP installer because I get the error message that the access to the file is Forbidden. Thanks for the heads up. This should be fixed now. Would you be willing to produce the HTML needed for the redesign? Edin Else i will :) Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
Hmm ok, so what does the parameter unicode.runtime_encoding = iso-8859-1 do? This means that, when unicode.semantics = on, internally everything is utf-16, event text read from iso-8859-1 script files and database data, so if I want to return iso-8859-1 data, I need to set unicode.output_encoding = iso-8859-1, and php will convert all echo'ed data from utf-16, is this it? If so, can I change unicode.output_encoding at runtime, with ini_set? - Original Message - From: Derick Rethans [EMAIL PROTECTED] To: Alexey Zakhlestin [EMAIL PROTECTED] Cc: Rangel Reale [EMAIL PROTECTED]; internals@lists.php.net Sent: Thursday, May 03, 2007 5:58 AM Subject: Re: [PHP-DEV] Trying to understand PHP6's unicode support On Thu, 3 May 2007, Alexey Zakhlestin wrote: php6 always handles all internal work in utf-8 No, it is UTF-16 internally. Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.463 / Virus Database: 269.6.1/776 - Release Date: 25/4/2007 12:19 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
Hello! I am trying to understand how PHP6 handling of unicode works, I think I am missing something. My config is: ; Unicode settings ; unicode.semantics = on unicode.runtime_encoding = iso-8859-1 unicode.script_encoding = iso-8859-1 unicode.output_encoding = utf-8 unicode.from_error_mode = U_INVALID_SUBSTITUTE unicode.from_error_subst_char = 3f unicode.fallback_encoding = iso-8859-1 I use a mysql database, with iso-8859-1 (Portuguese - latin 1) text, with accented characters. What I was trying to understand was, because unicode.runtime_encoding = iso-8859-1, I tought that all internal operations were done in this encoding, and only when outputting (unicode.output_encoding = utf-8) data would be converted to utf-8. So to me, I did a mysql query with latin1, data comes to my variables as iso-8859-1, I use them, and only when I echo'ed them, they would become utf-8, from a iso-8859-1-to-utf-8-like function. But when I do query in any record that have accented characters I get this warning (using mysql_fetch_assoc): -- Could not convert binary string to Unicode string (converter UTF-8 failed on bytes (0xE7) at offset 9) -- for all accented characters in all fields. The strange thing to me, is the mysql_fetch_assoc function give this error even before I accessed the field values, as I understanded from the above explanation. If I changed the set names query to: mysql_query('set names utf8', $this-mysql_link); then it works, but I would like to understand how this works, to make my program the right way from the start. Did I misundertood something? I think you are confusing PHP features with MySQL features. By running 'SET NAMES' query you set client, connection and result character sets in MySQL (see http://dev.mysql.com/doc/refman/4.1/en/charset.html). It is not related to PHP. MySQL has internal character set support since 4.1 version. -- Tomas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
On 5/3/07, Rangel Reale [EMAIL PROTECTED] wrote: Hmm ok, so what does the parameter unicode.runtime_encoding = iso-8859-1 do? This means that, when unicode.semantics = on, internally everything is utf-16, event text read from iso-8859-1 script files and database data, so if I want to return iso-8859-1 data, I need to set unicode.output_encoding = iso-8859-1, and php will convert all echo'ed data from utf-16, is this it? If so, can I change unicode.output_encoding at runtime, with ini_set? from: http://www.php.net/manual/nl/ini.php unicode.output_encoding : PHP_INI_ALL So yes, it can be set with ini_set. Tijnema - Original Message - From: Derick Rethans [EMAIL PROTECTED] To: Alexey Zakhlestin [EMAIL PROTECTED] Cc: Rangel Reale [EMAIL PROTECTED]; internals@lists.php.net Sent: Thursday, May 03, 2007 5:58 AM Subject: Re: [PHP-DEV] Trying to understand PHP6's unicode support On Thu, 3 May 2007, Alexey Zakhlestin wrote: php6 always handles all internal work in utf-8 No, it is UTF-16 internally. Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.463 / Virus Database: 269.6.1/776 - Release Date: 25/4/2007 12:19 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Help with the snaps site
Richard Quadling wrote: How about something along these lines ... (Not pretty as I'm crap at the design - sorry). http://rquadling.php1h.com/snap.html Eeek! ;) -- Michael -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] While-else
This fails the Make PHP code easier to read test I think. But it passes the I'm a lazy programmer test with flying colors! ;-) I mean seriously, what real value does this add to the language? Its just syntactic sugar to save yourself a few keystrokes. On 5/3/07, Andrew Brampton [EMAIL PROTECTED] wrote: - Original Message - On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote: Is it possible to make a while with a else-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: - ? $i = 1; while ($i = 10) { echo $i++; } else { echo The while couldn't be executed!; } ? - I have wanted to use this kind of syntax a couple of times, for example: ?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ? Otherwise I would write the above code as a while + a if. However I'm unsure if this syntax should be put into PHP, but I thought I'll just post a example of when I would use it. thanks Andrew -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: siml
submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: siml
On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 You don't need a CVS account for submitting one patch, send it to this list and someone will submit the patch. Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: siml
On 05/03/2007 05:24 PM, Tretter Simon wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 CVS account is not required to submit a patch. You can send it to [EMAIL PROTECTED] and CC spread maintainers. --- Wbr, Antony Dovgal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Trying to understand PHP6's unicode support
Hmm ok, so what does the parameter unicode.runtime_encoding = iso-8859-1 do? IIRC runtime_encoding is used to translate Unicode strings (UTF-16) to plain strings if some internal function accepts only plain strings. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: siml
Forwarding to the list... Tijnema -- Forwarded message -- From: Simon tretter [EMAIL PROTECTED] Hy, i've attached my patch, it's not perfect and it's not complete.. the codebase is a little bit awful and my code isn't much better ;), however - now it works with php 5.2.1 and spread 4.0. (only worked on connecting + sending spread messages, the rest of the code i didn't touched, so i don't know if every feature is working correctly..) ng siml ps.: sorry for my bad englisch - i'm an austrian student :) Tijnema ! schrieb: On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 You don't need a CVS account for submitting one patch, send it to this list and someone will submit the patch. Tijnema diff -r1.17 php_spread.c 121,125c121,127 PHP_ME_MAPPING(connect, spread_connect, NULL) PHP_ME_MAPPING(disconnect, spread_disconnect, NULL) PHP_ME_MAPPING(join,spread_join,NULL) PHP_ME_MAPPING(receive, spread_receive, NULL) {NULL, NULL, NULL} --- PHP_ME_MAPPING(connect, spread_connect, NULL, 0) PHP_ME_MAPPING(disconnect, spread_disconnect, NULL, 0) PHP_ME_MAPPING(join,spread_join,NULL, 0) PHP_ME_MAPPING(receive, spread_receive, NULL, 0) PHP_ME_MAPPING(multicast, multicast, NULL, 0) PHP_ME_MAPPING(multicast2, spread_multicast, NULL, 0) {NULL, NULL, NULL, 0} 308c310 php_error_docref(E_WARNING, Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d, spread_name, private_name, retval); --- php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d, spread_name, private_name, retval); 365a368 407,409c410 } else { RETURN_FALSE; } --- } 488c489 zval *group = NULL; --- zval **group = NULL; 490c491 char *message = NULL; --- zval **message = NULL; 496a498,499 #ifndef ZEND_ENGINE_2 503a507,508 #endif 511,513c516,549 default_mbox = SpG(default_conn); ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, Spread-FD, le_conn); if(Z_TYPE_P(group) == IS_STRING) { --- #ifdef ZEND_ENGINE_2 zval *this = getThis(); if (this) { ze_spread_object *obj = spread_fetch_object(this); if (ZEND_NUM_ARGS() 2) { WRONG_PARAM_COUNT; } if(zend_get_parameters_ex(2, group, message) == FAILURE) { return; } else { SEPARATE_ZVAL(group) SEPARATE_ZVAL(message) convert_to_string_ex(message); } mbox = obj-mbox; } else #endif { default_mbox = SpG(default_conn); ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, Spread-FD, le_conn); } if (!mbox) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, Resource or mailbox connection invalid.); RETURN_FALSE; } if((*group)-type == IS_STRING) { 515,517c551,553 convert_to_string_ex(group); tmpgrp = estrndup(group-value.str.val,group-value.str.len); if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, message_len, message) 0)) --- convert_to_string_ex(group); tmpgrp = estrndup((*group)-value.str.val,(*group)-value.str.len); if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, (*message)-value.str.len, (*message)-value.str.val) 0)) 519c555 zend_error(E_WARNING, SP_mulicast error(%d), sperrno); --- zend_error(E_WARNING, SP_multicast error(%d), sperrno); 522c558,559 RETURN_LONG(sperrno); --- // strange behaviour, SP_multicast (spread 4.0) always returns 0 in the case of no errors, so we return the length of our string ;) RETURN_LONG((*message)-value.str.len); 524c561 if(Z_TYPE_P(group) == IS_ARRAY) { --- if((*group)-type == IS_ARRAY) { 529,530c566,567 zend_hash_internal_pointer_reset_ex(group-value.ht, pos); while(zend_hash_get_current_data_ex(group-value.ht, (void **) tmp, pos) == SUCCESS n 100) --- zend_hash_internal_pointer_reset_ex((*group)-value.ht, pos); while(zend_hash_get_current_data_ex((*group)-value.ht, (void **) tmp, pos) == SUCCESS n 100) 535c572 zend_hash_move_forward_ex(group-value.ht, pos); ---
Re: [PHP-DEV] CVS Account Request: siml
On 5/3/07, Tijnema ! [EMAIL PROTECTED] wrote: Forwarding to the list... Tijnema -- Forwarded message -- From: Simon tretter [EMAIL PROTECTED] Hy, i've attached my patch, it's not perfect and it's not complete.. the codebase is a little bit awful and my code isn't much better ;), however - now it works with php 5.2.1 and spread 4.0. (only worked on connecting + sending spread messages, the rest of the code i didn't touched, so i don't know if every feature is working correctly..) Please send it to [EMAIL PROTECTED] not here. ng siml ps.: sorry for my bad englisch - i'm an austrian student :) Tijnema ! schrieb: On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 You don't need a CVS account for submitting one patch, send it to this list and someone will submit the patch. Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- David Coallier, Founder Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: siml
Ok, forwarding to the pecl-dev list now Tijnema On 5/3/07, David Coallier [EMAIL PROTECTED] wrote: On 5/3/07, Tijnema ! [EMAIL PROTECTED] wrote: Forwarding to the list... Tijnema -- Forwarded message -- From: Simon tretter [EMAIL PROTECTED] Hy, i've attached my patch, it's not perfect and it's not complete.. the codebase is a little bit awful and my code isn't much better ;), however - now it works with php 5.2.1 and spread 4.0. (only worked on connecting + sending spread messages, the rest of the code i didn't touched, so i don't know if every feature is working correctly..) Please send it to [EMAIL PROTECTED] not here. He's not on the list i guess, so i forward it now. ng siml ps.: sorry for my bad englisch - i'm an austrian student :) Tijnema ! schrieb: On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 You don't need a CVS account for submitting one patch, send it to this list and someone will submit the patch. Tijnema -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- David Coallier, Founder Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: siml
On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 What you did is the right thing, submit a bug report and wait a bit until one (in this case, it will certainly be me) answer. Further discussions about this patch will take place there. Regards, --Pierre -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants
Hi, In this way, classes can be considered as polymorphism, just like objects. So is it OK to allow abstract static function in abstract class to support this feature directory? Currently it is forbidden in HEAD, only interfaces can have static function. Thanks 2007/4/27, Etienne Kneuss [EMAIL PROTECTED]: Hi, I've already proposed that 1-2 months ago, but now seems to be a good time to discuss new things, so let's try again: I believe it would be nice to be able to dynamically reference static members, constants, and methods. Currently, there is no way to do that and the only way would be to create a static method and use call_user_func(array($classname, 'getThat')); In other words: class A { public static $foo = 'value1'; const gee = 'value2'; public static function bar() { return 'value3'; } // old way: public static function getFoo() { return self::$foo; } public static function getGee() { return self::gee; } } $classname = 'A'; echo $classname::$foo; // value1 echo $classname::gee; // value2 echo $classname::bar(); // value3 // --- instead of: --- $classname = 'A'; echo call_user_func(array($classname, 'getFoo')); // value1 echo call_user_func(array($classname, 'getGee')); // value2 echo call_user_func(array($classname, 'bar'));// value3 which is quite slow. Please take a look at the patch[1] I made for it. Comments would be appreciated! Regards, 1: http://patches.colder.ch/Zend/dynamic-static-calls.patch?markup -- Etienne Kneuss http://www.colder.ch [EMAIL PROTECTED] Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal Index: Zend/zend_language_parser.y === RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.179 diff -u -r1.179 zend_language_parser.y --- Zend/zend_language_parser.y 4 Mar 2007 16:25:57 - 1.179 +++ Zend/zend_language_parser.y 6 Mar 2007 14:43:49 - @@ -642,6 +642,12 @@ | fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); } function_call_parameter_list ')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); } + function_call_parameter_list + ')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); } + function_call_parameter_list + ')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} | variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call($1 TSRMLS_CC); } function_call_parameter_list ')' { zend_do_end_function_call($1, $$, $4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} @@ -795,6 +801,11 @@ static_member: fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member($$, $1 TSRMLS_CC); } +| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member($$, $1 TSRMLS_CC); } +; + +variable_class_name: + reference_variable { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class($$, $1 TSRMLS_CC); } ; @@ -930,6 +941,7 @@ class_constant: fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant($$, $1, $3, ZEND_RT TSRMLS_CC); } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant($$, $1, $3, ZEND_RT TSRMLS_CC); } ; %% Index: tests/lang/041.phpt === RCS file: tests/lang/041.phpt diff -N tests/lang/041.phpt --- /dev/null 1 Jan 1970 00:00:00 - +++ tests/lang/041.phpt 6 Mar 2007 14:43:49 - @@ -0,0 +1,14 @@ +--TEST-- +Dynamic access of static members +--FILE-- +?php +class A { +publicstatic $b = 'foo'; +} +$classname = 'A'; +echo $classname::$b; +? +===DONE=== +--EXPECT-- +foo +===DONE=== Index: tests/lang/042.phpt === RCS file: tests/lang/042.phpt diff -N tests/lang/042.phpt --- /dev/null 1 Jan 1970 00:00:00 - +++ tests/lang/042.phpt 6 Mar 2007 14:43:49 - @@ -0,0 +1,14 @@ +--TEST-- +Dynamic access of constants
Re: [PHP-DEV] While-else
On 28/04/07, Pelle Ravn Rosfeldt [EMAIL PROTECTED] wrote: Hi there. Is it possible to make a while with a else-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: - ? $i = 1; while ($i = 10) { echo $i++; } else { echo The while couldn't be executed!; } ? - Python Perl already have this function. So why not PHP? The 'but everyone else is doing it' argument is particularly weak when it's not actually accurate. $ man perlsyn The following compound statements may be used to control flow: [...] LABEL while (EXPR) BLOCK LABEL while (EXPR) BLOCK continue BLOCK $ perl -le '$i = 99; while ($i 10) { $i++; } else { print Oh...; }' syntax error at -e line 1, near } else I can't see any point in it myself. It doesn't read naturally and it doesn't add anything that you don't get by preceding your while with a simple if statement. -robin -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants
I've already proposed that 1-2 months ago, but now seems to be a good time to discuss new things, so let's try again: I believe it would be nice to be able to dynamically reference static members, constants, and methods. Currently, there is no way to do that and the only way would be to create a static method and use call_user_func(array($classname, 'getThat')); Could you describe a couple of use cases where you would use such things (i.e. in real world scripts/libraries)? -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: siml
Hy, i've attached my patch, it's not perfect and it's not complete.. the codebase is a little bit awful and my code isn't much better ;) , however - now it works with php 5.2.1 and spread 4.0. (only worked on connecting + sending spread messages, the rest of the code i didn't touched, so i don't know if every feature is working correctly..) ng siml ps.: sorry for my bad englisch - i'm an austrian student :) Tijnema ! schrieb: On 5/3/07, Tretter Simon [EMAIL PROTECTED] wrote: submitting a patch for a php extension in pecl tree (spread) i made a patch for php5.2 and spread 4.0 You don't need a CVS account for submitting one patch, send it to this list and someone will submit the patch. Tijnema diff -r1.17 php_spread.c 121,125c121,127 PHP_ME_MAPPING(connect, spread_connect, NULL) PHP_ME_MAPPING(disconnect, spread_disconnect, NULL) PHP_ME_MAPPING(join,spread_join,NULL) PHP_ME_MAPPING(receive, spread_receive, NULL) {NULL, NULL, NULL} --- PHP_ME_MAPPING(connect, spread_connect, NULL, 0) PHP_ME_MAPPING(disconnect, spread_disconnect, NULL, 0) PHP_ME_MAPPING(join,spread_join,NULL, 0) PHP_ME_MAPPING(receive, spread_receive, NULL, 0) PHP_ME_MAPPING(multicast, multicast, NULL, 0) PHP_ME_MAPPING(multicast2, spread_multicast, NULL, 0) {NULL, NULL, NULL, 0} 308c310 php_error_docref(E_WARNING, Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d, spread_name, private_name, retval); --- php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d, spread_name, private_name, retval); 365a368 407,409c410 } else { RETURN_FALSE; } --- } 488c489 zval *group = NULL; --- zval **group = NULL; 490c491 char *message = NULL; --- zval **message = NULL; 496a498,499 #ifndef ZEND_ENGINE_2 503a507,508 #endif 511,513c516,549 default_mbox = SpG(default_conn); ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, Spread-FD, le_conn); if(Z_TYPE_P(group) == IS_STRING) { --- #ifdef ZEND_ENGINE_2 zval *this = getThis(); if (this) { ze_spread_object *obj = spread_fetch_object(this); if (ZEND_NUM_ARGS() 2) { WRONG_PARAM_COUNT; } if(zend_get_parameters_ex(2, group, message) == FAILURE) { return; } else { SEPARATE_ZVAL(group) SEPARATE_ZVAL(message) convert_to_string_ex(message); } mbox = obj-mbox; } else #endif { default_mbox = SpG(default_conn); ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, Spread-FD, le_conn); } if (!mbox) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, Resource or mailbox connection invalid.); RETURN_FALSE; } if((*group)-type == IS_STRING) { 515,517c551,553 convert_to_string_ex(group); tmpgrp = estrndup(group-value.str.val,group-value.str.len); if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, message_len, message) 0)) --- convert_to_string_ex(group); tmpgrp = estrndup((*group)-value.str.val,(*group)-value.str.len); if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, (*message)-value.str.len, (*message)-value.str.val) 0)) 519c555 zend_error(E_WARNING, SP_mulicast error(%d), sperrno); --- zend_error(E_WARNING, SP_multicast error(%d), sperrno); 522c558,559 RETURN_LONG(sperrno); --- // strange behaviour, SP_multicast (spread 4.0) always returns 0 in the case of no errors, so we return the length of our string ;) RETURN_LONG((*message)-value.str.len); 524c561 if(Z_TYPE_P(group) == IS_ARRAY) { --- if((*group)-type == IS_ARRAY) { 529,530c566,567 zend_hash_internal_pointer_reset_ex(group-value.ht, pos); while(zend_hash_get_current_data_ex(group-value.ht, (void **) tmp, pos) == SUCCESS n 100) --- zend_hash_internal_pointer_reset_ex((*group)-value.ht, pos); while(zend_hash_get_current_data_ex((*group)-value.ht, (void **) tmp, pos) == SUCCESS n 100) 535c572 zend_hash_move_forward_ex(group-value.ht, pos); --- zend_hash_move_forward_ex((*group)-value.ht, pos); 539c576
Re: [PHP-DEV] Trying to understand PHP6's unicode support
On Thu, 2007-05-03 at 14:29 +0300, Tomas Kuliavas wrote: I think you are confusing PHP features with MySQL features. By running 'SET NAMES' query you set client, connection and result character sets in MySQL (see http://dev.mysql.com/doc/refman/4.1/en/charset.html). It is not related to PHP. MySQL has internal character set support since 4.1 version. But PHP 6 still needs to get the data in a proper encoding so it matters. Please see http://news.php.net/php.i18n/1062 until posting 1066 for another discussion started by Rangel Reale about the same issue. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] While-else
On Thu, May 3, 2007 2:34 am, Andrew Brampton wrote: - Original Message - On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote: Is it possible to make a while with a else-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: - ? $i = 1; while ($i = 10) { echo $i++; } else { echo The while couldn't be executed!; } ? - I have wanted to use this kind of syntax a couple of times, for example: ?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ? Otherwise I would write the above code as a while + a if. However I'm unsure if this syntax should be put into PHP, but I thought I'll just post a example of when I would use it. I can understand how it works now, and where you'd use it... And I still don't care for it... I mean, 'else' just doesn't go with 'while', to me... And you rarely need something as convoluted as the other example. while ($line = mysql_fetch_array(...)){ echo $line; //not really right, btw... :-) } if (!mysql_num_rows(...)){ echo no records; } So, really, it just makes confusing PHP code, that doesn't seem to save much, in most real-world cases I can think of. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants
Hi, Stanislav Malyshev wrote: Could you describe a couple of use cases where you would use such things (i.e. in real world scripts/libraries)? Sure, let's take an example: You have a library that uses a factory pattern, but you'd like to cache those already generated objects in a static variable in the class. Now, this feature is required in many classes and you'd not like to duplicate too much code, so a solution would be: class MySuperClass { private static $_objectsLoaded = array(); public static function factory($pkId, $classname = __CLASS__) { if(isset($_objectsLoaded[$classname][$pkId])) { return $_objectsLoaded[$classname][$pkId]; } $o = new $classname(); //load stuff from the database $table = $classname::$_table; $pkField = $classname::$_pkField; // build query using $table, and $pkField, load stuff into $o, etc.. if(!is_array(self::$_objectsLoaded[$classname])) { self::$_objectsLoaded[$classname] = array(); } self::$_objectsLoaded[$classname][$pkId] = $o; return $o; } public static function create($classname = __CLASS__) { $o = new $classname(); // ... return $o; } } class MyClass extends MySuperClass { protected static $_pkField = 'id'; protected static $_table = 'theTable'; public static factory($pkId, $classname = __CLASS__) { return parent::factory($pkId,$classname); } public static create($classname = __CLASS__) { return parent::create($classname); } // ... } There may be some typos in the code above that makes its syntax incorrect, but the idea is here. Now, as you can see, because late static binding is not yet implemented and probably never will be because of the overhead it might introduce, you've to pass the classname as a parameter and use it to request things from the child's class, at this point, being able to do that using that $classname:: shortcut is quite elegant, instead of having to use overkill call_user_func calls as all those _get*() methods would have to be redefined in every the child classes. I wouldn't mind having to use multiple call_user_func calls for that purpose if I knew it was too hard to implement that $classname:: thing, but it's so easy that I really believe it's a feature worth having. And PHP is also about multiple ways of doing something, right ? :) -- Etienne Kneuss http://www.colder.ch [EMAIL PROTECTED] Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] While-else
Am Donnerstag, 3. Mai 2007 09:34 schrieb Andrew Brampton: I have wanted to use this kind of syntax a couple of times, for example: ?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ? This example leaves me speechless.:) Regard, Oliver -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Help with the snaps site
Edin Kadribasic schrieb: The page is a bit confusing and I didn't want too much new stuff to it without thinking about it first. Your suggestion is promising, but it might be a bit too wide for people that have smaller screen resolutions. I think we need to make it look good at 1024x768. Yes, the page is too wide. The reason for this is that this is actually not a website but a rearranged screenshot. I noticed too late that the page has a bad width. There are some things you have missed. There are two different source bundles (gz and bz2). Next build depends on the system (source or bins) and the PHP version (we build some windows snapshots more often than others). Maybe I missed the things because I was led from the dream that the different build intervals could be simplified too. ;) But you are right these are things I didn't pay attention to. I could make a new suggestion tomorrow and try to integrate the missing things. Thanks for the heads up. This should be fixed now. This was a very fast fix and indeed I can now download the installer. Would you be willing to produce the HTML needed for the redesign? Unfortunately my knowledge about HTML and CSS is very limited, so I don't think the page would look very good in case I did it. I would prefer if somebody with more knowledge could do it. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php