[PHP] Using variable content to name a class
PHP list, I suspect this is a rather basic concept, but I could not find the specifics in the online manual. I have a set of classes, and the name of each class is stored in a column in a table in my MySQL database. When I want to create an object from one of my classes, I also query the database to get a bunch of data the object needs, along with its name. So what I end up with is a variable with the name of the class that I want to use stored as a string. This means that I want to create an object by naming which class with the contents of a variable: $className = "nameFromDatabase"; $object = new $className(); Is this possible? I hope I've asked my question clearly. Thank you for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using variable content to name a class
Dave M G wrote: PHP list, I suspect this is a rather basic concept, but I could not find the specifics in the online manual. I have a set of classes, and the name of each class is stored in a column in a table in my MySQL database. When I want to create an object from one of my classes, I also query the database to get a bunch of data the object needs, along with its name. So what I end up with is a variable with the name of the class that I want to use stored as a string. This means that I want to create an object by naming which class with the contents of a variable: $className = "nameFromDatabase"; $object = new $className(); Is this possible? If in doubt, test it out ;) Yes, it will work. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using variable content to name a class
Chris, Thank you for replying. $object = new $className(); Is this possible? If in doubt, test it out ;) Yes, it will work. Oh, that's actually the code I can use? I just wrote it as an explanatory aid, not thinking that it could be literally done like that. I assumed there was a specific command I was missing. Well, anyway, I guess I've stumbled on the right syntax. Thank you for pointing it out to me. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How do I make a HTML tree for a set of nodes?
Niels wrote: > Hi, > > > I have a set of nodes. Each node has a parent and so the set can be > thought of as a tree. I want to show that tree somehow on a webpage, > served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm > looking for is an output of DIVs or tablecells, showing the nodes and > their connections. It's not a trivial task, IMO, but doable. Possibly > somebody has already made something similiar, but I can't find anything on > Google. Can anybody point me to helpful information? > > Thanks, > Niels For the concept of storage, you might want to look at http://www.sitepoint.com/article/hierarchical-data-database For a very simple implementation of the idea for display and editing, http://www.auseinet.com/test/treeedit.php I can provide the code for the above if you want it. Cheers -- David Robley Death is a nonmaskable interrupt. Today is Sweetmorn, the 10th day of Confusion in the YOLD 3172. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unicode
At 7:08 PM -0700 6/4/06, Rasmus Lerdorf wrote: >Larry Garfield wrote: >>In C or C++, yes. In PHP, do not assume the same string->number mapping. >>Numeric definition is irrelevant. > >Right, and now bring Unicode into the picture and this becomes even more true. > -Rasmus I know there's always RTFM, but if you would care to discuss it, I would like to know why. How does php handle Unicode code-points and char-sets? Thanks. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pager fix - cash offered
I need this pager fixed http://scottishsocialnetworks.org/editorx.php http://scottishsocialnetworks.org/editorx.php http://scottishsocialnetworks.org/class.pager.phps The problem is it resets when the numbered pages are pressed at the bottom. I think the query string gets reset when the page is self submitted I need it to page the results correctly. I can pay by paypal as soon as someone provides (i) an agreed cost (ii) a working solution (iii) a brief explanation. I do not think this is a big job but I do not have enough time to fix it and need it done asap. thanks, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How do I make a HTML tree for a set of nodes?
On Monday 05 June 2006 13:32, David Robley wrote: > Niels wrote: > >> Hi, >> >> >> I have a set of nodes. Each node has a parent and so the set can be >> thought of as a tree. I want to show that tree somehow on a webpage, >> served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm >> looking for is an output of DIVs or tablecells, showing the nodes and >> their connections. It's not a trivial task, IMO, but doable. Possibly >> somebody has already made something similiar, but I can't find anything >> on Google. Can anybody point me to helpful information? >> >> Thanks, >> Niels > > For the concept of storage, you might want to look at > > http://www.sitepoint.com/article/hierarchical-data-database > This I had already found. But it's a very basic article, and it's not about how to transform a set of data into a nice looking piece of HTML. It does show some cool trees, but the display_tree function shown just uses indents, like my own. > For a very simple implementation of the idea for display and editing, > > http://www.auseinet.com/test/treeedit.php > > I can provide the code for the above if you want it. > Thanks, but this is more or less what I have. If you can add branches to that, I'd like to hear more. Thank you for your answer, I appreciate it! Niels -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Retrieving Content
chris smith wrote: On 6/3/06, Adam Zey <[EMAIL PROTECTED]> wrote: Rodrigo de Oliveira Costa wrote: > I just discovered the problem I have to retrieve the output of the > site and not the url since its dynamic. Ca I do it like retrieve the > output of this url: > > www.tryout.com/1/2/ > > And of course store it on a variable? How to do it? I founr the func > below but couldnt understand how to make it work with a url. > > Thanks guys, > Rodrigo > > > ob_start(); > include('file.php'); // Could be a site here? What should I do to > retrieve it from an url? > $output = ob_get_contents(); > ob_end_clean(); Umm. As I said, just use file_get_contents(): $file = file_get_contents("http://www.tryout.com/1/2/";); Assuming allow_url_fopen is on. If not, you could try using curl - see http://www.php.net/curl allow_url_fopen is on by default, and curl requires custom compile-time options. Considering that, it is logical that if the user can't enable allow_url_fopen, they're not going to be allowed to recompile PHP. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SPL Iterator and Associative Array
Jason Karns wrote: -Original Message- From: Greg Beaver [mailto:[EMAIL PROTECTED] Sent: Friday, June 02, 2006 10:39 PM To: Jason Karns Cc: php-general@lists.php.net Subject: Re: SPL Iterator and Associative Array Jason Karns wrote: I'm going to try my best to explain what I'm trying to do. I have my own class that has an array member. This class itself implements Iterator. One of the fields in the array is itself an array that I would like to iterate over. Here's some code: Hi Jason, The code you pasted is littered with fatal errors and bugs (I marked one example with "^^" above). Please paste a real batch of code that you've tested and reproduces the error and that will be much more helpful. The PHP version would be helpful to know as well. Greg -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.1/354 - Release Date: 6/1/2006 load($file); } public function load($file){ ... $keys = array(); $values = array(); foreach ($projects as $project) { $small = array(); $big = array(); foreach ($xpath->query('showcase/images/screenshot/thumbnail',$project) as $img){ $small[] = $img->nodeValue;} foreach ($xpath->query('showcase/images/screenshot/src',$project) as $img){ $big[] = $img->nodeValue;} $keys[] = $xpath->query('@id',$project)->item(0)->nodeValue; $values[] = array( 'title'=>$xpath->query('showcase/title',$project)->item(0)->nodeValue, 'href'=>$xpath->query('livesite',$project)->item(0)->nodeValue, 'clip'=>$xpath->query('showcase/images/feature/thumbnail',$project)->item(0) ->nodeValue, 'big'=>$big, 'small'=>$small, 'text'=>$xpath->query('showcase/description',$project)->item(0)->nodeValue); } $this->projects = array_combine($keys,$values); } function &smalls($x=null){ if(is_null($x) or !key_exists($x,$this->projects)) $x = $this->key(); return $this->projects[$x]['small']; } function small_src($x=null){ if(is_null($x) or !key_exists($x,$this->projects)) $x = $this->key(); return current($this->projects[$x]['small']); } function small($x=null){ if(is_null($x) or !key_exists($x,$this->projects)) $x = $this->key(); return ''.$this->small_img($x).''; } } ?> smalls()); while($s = current($folio->smalls())){ echo $folio->small(); next($folio->smalls()); } foreach($folio->smalls() as $s){ echo $folio->small(); } ?> Production server will be PHP 5.1.2, developing on 5.0.5 I am also considering making my own 'project' object and having Folio have an array of 'projects' rather than using the array of associative arrays. Would this provide a solution? Thanks, Jason If you're going to be using 5.1.2 in production, develop on 5.1.2. PHP doesn't guarantee backwards compatibility, especially in such a big change as 5.0.x -> 5.1.x. Better to develop on 5.1.2 from the start than to develop on 5.0.5, put the code on 5.1.2, get a bunch of errors, and then have to develop again on 5.1.2 to fix the bugs. Not to mention that any testing done with 5.0.5 is invalid since you can't be sure that things will behave the same with the different production version. You may even waste time working around bugs in 5.0.5 that don't exist in 5.1.2. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP/MySQL question
I have a php form that pulls data from the database (hence the problems) I need to do an OR search on three columns, and AND the rest, anyone have a good way to do this? So far my searching on the MySQL lists have been fruitless more then anything, and I figured we've probably come across this ourselves at some point. Here's the code I have so far: $query = "select * from honorclub"; if ($dead != "" || $unknown != "" || $name != "" || $county != "" || $year != "" || $countynow != "" || $state != "") {$query .= " WHERE ";} if ($dead == "") {$query .= " `Deceased`='N' AND";} if ($unknown == "") {$query .= " `USPS_Unknown`='N' AND ";} if ($name != "") {$query .= " `Last_Name` like '$name%' AND ";} if ($county != "") {$query .= " `County` like '$county' AND ";} if ($year != "") {$query .= " `Year_Tapped` like '$year' AND ";} if ($countynow != "") {$query .= " `County_Now` like '$countynow' AND ";} if ($state != "") {$query .= " `State_Now` like '$state' AND ";} $query = rtrim($query," AND"); $query .= " order by $order_by"; What needs to be 'OR' is the $name section to be: $query .= "`Last_Name` like '%$name%' OR `First_Name` like '%$name%' OR `Maiden_Name` like '%$name%'"; Thanks, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: pager fix - cash offered
I could fix it for you, but, i just can look at it in the evening when i´ll be at home. If it could be, wait for my contac e-mail this evening. Thanks. ""Ross"" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > > I need this pager fixed > > http://scottishsocialnetworks.org/editorx.php > > http://scottishsocialnetworks.org/editorx.php > > http://scottishsocialnetworks.org/class.pager.phps > > > The problem is it resets when the numbered pages are pressed at the > bottom. I think the query string gets reset when the page is self > submitted > > I need it to page the results correctly. I can pay by paypal as soon as > someone provides (i) an agreed cost (ii) a working solution (iii) a brief > explanation. > > I do not think this is a big job but I do not have enough time to fix it > and need it done asap. > > thanks, > > Ross > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/MySQL question
[snip] I need to do an OR search on three columns, and AND the rest, anyone have a good way to do this? So far my searching on the MySQL lists have been fruitless more then anything, and I figured we've probably come across this ourselves at some point. [/snip] More of a MySQL question, but easily enough answered; Always group the OR with parenthese and the AND individually. Write the query and test with MySQL before placing into PHP code; SELECT * FROM `table` WHERE (`foo` = 'bar' OR `foo` = 'glorp' OR `sqirk` = 'glorp') AND `today` = CURDATE() AND `userID` = 'Marvin' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL question
On Mon, June 5, 2006 10:32 am, Wolf wrote: > I have a php form that pulls data from the database (hence the > problems) > > I need to do an OR search on three columns, and AND the rest, anyone > have a good way to do this? So far my searching on the MySQL lists > have > been fruitless more then anything, and I figured we've probably come > across this ourselves at some point. > > Here's the code I have so far: I'm confused just by the indenting (or lack thereof) but one standard technique is to start off with a "yeast" such as: $query = "select * from honorclub "; //Fix * to be actual columns! $query .= " WHERE 1 "; if ($dead != "" ...){ $query .= " AND Deceased = 'N' "; } $query .= " AND (First_name like '%$name%' or Last_name like '%$name%' ) "; > $query = "select * from honorclub"; > if ($dead != "" || $unknown != "" || $name != "" || $county != "" || > $year != "" || $countynow != "" || $state != "") > {$query .= " WHERE ";} > if ($dead == "") > {$query .= " `Deceased`='N' AND";} > if ($unknown == "") > {$query .= " `USPS_Unknown`='N' AND ";} > if ($name != "") > {$query .= " `Last_Name` like '$name%' AND ";} > if ($county != "") > {$query .= " `County` like '$county' AND ";} > if ($year != "") > {$query .= " `Year_Tapped` like '$year' AND ";} > if ($countynow != "") > {$query .= " `County_Now` like '$countynow' AND ";} > if ($state != "") > {$query .= " `State_Now` like '$state' AND ";} > $query = rtrim($query," AND"); > $query .= " order by $order_by"; > > What needs to be 'OR' is the $name section to be: > $query .= "`Last_Name` like '%$name%' OR `First_Name` like '%$name%' > OR > `Maiden_Name` like '%$name%'"; > > Thanks, > Wolf > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Explicit Stream Flush with fsockopen()
http://php.net/fflush On Sun, June 4, 2006 9:51 pm, Oliver John V. Tibi wrote: > Hi Guys, > > I know this may sound fundamental to some of you, but do you know any > way of explicitly flushing out stream buffers off to the socket using > fsockopen()/fputs() combos? Hope to hear from you soon. > > Note: I'm not using http, and I'm connecting to some other arbitrary > port other than http, so I don't know if ob_flush() and its family of > functions will work. > > Thanks! :) > > -- > Oliver John V. Tibi > Software Programmer/Web Application Developer > IAMD Software Solutions > [EMAIL PROTECTED] > "Live free() or die()." > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] i have a problem inserting blob data larger than 1 mb
hi list, i am facing a problem inserting binary data into a blob field.this is my /etc/my.cnf file. [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock connect_timeout=60 [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid please help me. and this is what i get after running the comand mysql --help ... ... ... Possible variables for option --set-variable (-O) are: connect_timeout current value: 0 max_allowed_packetcurrent value: 16777216 net_buffer_length current value: 16384 select_limit current value: 1000 max_join_size current value: 100 i guess there is some problem with connect_timeout.
Re: [PHP] When is "z" != "z" ?
I know this discussion doesn't need to continue any further..hah.. but I think the biggest confusion people are having is that they're looking at two things and assuming that PHP operates the same on both and these two things serve different purposes. 1. Incrementing strings: Best example giving was "File1"++ == "File2" or "FileA"++ == "FileB". In that case, wouldn't you want it to go from FileZ to FileAA? Makes sense right? 2. Comparing "greatness" of strings: Rasmus mentioned this earlier, but I wante to illustrate it a little more because I think it was overlooked. If you have a list of names, for instance, and you alphabetize them, you'd get something like this: Bob Brendan Burt Frank Fred Just become a name is longer doesn't mean it comes after the rest of the names in the list. So in that vane, anything starting in "A" will never be > something starting with a "Z". a < z aa < z aaa < z because: a aa aaa z When using interation and a for loop and " <= z" it gets to "y" and it's true, gets to "z" and it's still true, then increments to "az" and yup.. still < "z". As mentioned, it's not until you get to something starting in "z" with something after it that you're > "z". So hopefully that makes a little more sense. -TG = = = Original message = = = tedd wrote: > At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: >>> I agree with [1] and [2], but [3] is where we part company. You see, if you >>> are right, then "aaa" would also be less than "z", but that doesn't appear >>> so. >> Of course it is. >> >> php -r 'echo "aaa" < "z";' >> 1 > > You missed the point, why does -- > > for ($i="a"; $i<="z"; $i++) > > echo($i); > > > -- not continue past "aaa"? Clearly, if "aaa" is less than "z" then why does > the loop stop at "yz"? I thought I explained that a few times. The sequence is: a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab Your loop stops at yz and doesn't get anywhere near aaa because za > z -Rasmus ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: i have a problem inserting blob data larger than 1 mb
sunaram patir wrote: hi list, i am facing a problem inserting binary data into a blob field.this is my /etc/my.cnf file. [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock connect_timeout=60 [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid please help me. and this is what i get after running the comand mysql --help ... ... ... Possible variables for option --set-variable (-O) are: connect_timeout current value: 0 max_allowed_packetcurrent value: 16777216 net_buffer_length current value: 16384 select_limit current value: 1000 max_join_size current value: 100 i guess there is some problem with connect_timeout. Blobs have a max size like every other variable. Have you tried mediumblob and longblob yet? They both have more capacity. I suggest you refer to the MySQL manual. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Sat, June 3, 2006 8:40 pm, George Babichev wrote: > Hello everyone! I wrote a blog application, but now for the admin > panel, i > am trying to add a feature to delete blog posts. It would show the > title of > the post next to it, and have a delete link which would delete it. How > would > I do this? I mean if I have multiple blog entry's, how would I delete > them > without using php my admin? The blog entries should all have a unique ID, such as an auto_increment, and you would embed that in the delete form: In the processing page: -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Sun, June 4, 2006 3:11 am, Rabin Vincent wrote: > You may find it easier to generate links of the form > delete.php?id=1, etc. Then you won't have to use a seperate > form for each link. The id will be available in delete.php > in $_GET. The same sanity checking applies in this case too. Gah! That violates the HTTP spec for GET versus POST, to start with. Note that the solution I presented only needs ONE form tag, as the ID is embedded into the KEY of the name of the submit button. Might seem funky at first, but it works very well, and is one of the reasons I love PHP. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
-TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to other languages, I just tried it on a lark just to see what would happen. Okay, so I found out it's limitations and quirks. But, you must admit that it is confusing to have a loop that goes from "a" to "z" and considers "aa" but not "aaa". Now, if the loop just went from a to z, then I would think that would be logical. But I fail to see the logic behind considering "aa" but not "aaa" in the evaluation. But then again, I'm not that informed. Enough said. tedd At 12:21 PM -0400 6/5/06, <[EMAIL PROTECTED]> wrote: >I know this discussion doesn't need to continue any further..hah.. but I think >the biggest confusion people are having is that they're looking at two things >and assuming that PHP operates the same on both and these two things serve >different purposes. > >1. Incrementing strings: Best example giving was "File1"++ == "File2" or >"FileA"++ == "FileB". In that case, wouldn't you want it to go from FileZ to >FileAA? Makes sense right? > >2. Comparing "greatness" of strings: Rasmus mentioned this earlier, but I >wante to illustrate it a little more because I think it was overlooked. If >you have a list of names, for instance, and you alphabetize them, you'd get >something like this: > >Bob >Brendan >Burt >Frank >Fred > >Just become a name is longer doesn't mean it comes after the rest of the names >in the list. So in that vane, anything starting in "A" will never be > >something starting with a "Z". a < z aa < z aaa < z because: > >a >aa >aaa >z > >When using interation and a for loop and " <= z" it gets to "y" and it's true, >gets to "z" and it's still true, then increments to "az" and yup.. still < >"z". As mentioned, it's not until you get to something starting in "z" with >something after it that you're > "z". > >So hopefully that makes a little more sense. > >-TG > > > >= = = Original message = = = > >tedd wrote: >> At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then "aaa" would also be less than "z", but that doesn't appear so. >>> Of course it is. >>> >>> php -r 'echo "aaa" < "z";' >>> 1 >> >> You missed the point, why does -- >> >> for ($i="a"; $i<="z"; $i++) >> >> echo($i); >> >> >> -- not continue past "aaa"? Clearly, if "aaa" is less than "z" then why does >> the loop stop at "yz"? > >I thought I explained that a few times. The sequence is: > >a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab > >Your loop stops at yz and doesn't get anywhere near aaa because za > z > >-Rasmus > > >___ >Sent by ePrompter, the premier email notification software. >Free download at http://www.ePrompter.com. > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Sun, June 4, 2006 3:11 am, Rabin Vincent wrote: You may find it easier to generate links of the form delete.php?id=1, etc. Then you won't have to use a seperate form for each link. The id will be available in delete.php in $_GET. The same sanity checking applies in this case too. Gah! That violates the HTTP spec for GET versus POST, to start with. How so? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
tedd wrote: -TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to other languages, I just tried it on a lark just to see what would happen. Okay, so I found out it's limitations and quirks. But, you must admit that it is confusing to have a loop that goes from "a" to "z" and considers "aa" but not "aaa". Now, if the loop just went from a to z, then I would think that would be logical. But I fail to see the logic behind considering "aa" but not "aaa" in the evaluation. But then again, I'm not that informed. Enough said. tedd At 12:21 PM -0400 6/5/06, <[EMAIL PROTECTED]> wrote: I know this discussion doesn't need to continue any further..hah.. but I think the biggest confusion people are having is that they're looking at two things and assuming that PHP operates the same on both and these two things serve different purposes. 1. Incrementing strings: Best example giving was "File1"++ == "File2" or "FileA"++ == "FileB". In that case, wouldn't you want it to go from FileZ to FileAA? Makes sense right? 2. Comparing "greatness" of strings: Rasmus mentioned this earlier, but I wante to illustrate it a little more because I think it was overlooked. If you have a list of names, for instance, and you alphabetize them, you'd get something like this: Bob Brendan Burt Frank Fred Just become a name is longer doesn't mean it comes after the rest of the names in the list. So in that vane, anything starting in "A" will never be > something starting with a "Z". a < z aa < z aaa < z because: a aa aaa z When using interation and a for loop and " <= z" it gets to "y" and it's true, gets to "z" and it's still true, then increments to "az" and yup.. still < "z". As mentioned, it's not until you get to something starting in "z" with something after it that you're > "z". So hopefully that makes a little more sense. -TG = = = Original message = = = tedd wrote: At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then "aaa" would also be less than "z", but that doesn't appear so. Of course it is. php -r 'echo "aaa" < "z";' 1 You missed the point, why does -- for ($i="a"; $i<="z"; $i++) echo($i); -- not continue past "aaa"? Clearly, if "aaa" is less than "z" then why does the loop stop at "yz"? I thought I explained that a few times. The sequence is: a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab Your loop stops at yz and doesn't get anywhere near aaa because za > z -Rasmus ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php As mentioned before, discussion aside, you can do what you want with range and a foreach: foreach (range('a', 'z') as $char) { echo $char; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Mon, June 5, 2006 12:41 am, Rabin Vincent wrote: > I don't see how POST is better/more secure for a delete action. If you don't see how it's better, then READ THE HTTP SPECS!!! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Mon, June 5, 2006 11:52 am, Chris Boget wrote: >> On Sun, June 4, 2006 3:11 am, Rabin Vincent wrote: >>> You may find it easier to generate links of the form >>> delete.php?id=1, etc. Then you won't have to use a seperate >>> form for each link. The id will be available in delete.php >>> in $_GET. The same sanity checking applies in this case too. >> Gah! >> That violates the HTTP spec for GET versus POST, to start with. > > How so? http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] .htaccess - change index.php to index.abc
On Sat, June 3, 2006 6:47 pm, Labunski wrote: > What should I change in .htaccess, so that visitors will see index.abc > instead of index.php. > I just wanna hide file's extension. Assuming you use PHP as Module and not CGI: ForceType application/x-httpd-php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
On Mon, 2006-06-05 at 12:49, tedd wrote: > -TG: > > Thanks for your explanation and time. > > Normally, I don't alpha++ anything -- not to criticize others, but to me it > doesn't make much sense to add a number to a character. But considering the > php language is so string aware, as compared to other languages, I just tried > it on a lark just to see what would happen. > > Okay, so I found out it's limitations and quirks. > > But, you must admit that it is confusing to have a loop that goes from "a" to > "z" and considers "aa" but not "aaa". > > Now, if the loop just went from a to z, then I would think that would be > logical. But I fail to see the logic behind considering "aa" but not "aaa" in > the evaluation. But then again, I'm not that informed. > > Enough said. NO! More must be said!! a <= z b <= z c <= z ... y <= z z <= z aa <= z ab <= z ac <= z ... az <= z ba <= z bb <= z bc <= z ... cz <= z ... dz <= z ... ... ... yx <= z yy <= z yz <= z za > z Sooo, the comparisons stop before we get to aaa and so aaa is never reached. za is the last comparison to occur at which point the test fails and the loop stops. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieve output from HTML or PHP file
On Fri, June 2, 2006 12:27 pm, Rodrigo de Oliveira Costa wrote: > Can I do the below to an URL, like retrieving the output of a site and > store it on a variable? http://php.net/'); ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If value is odd or not
On Fri, June 2, 2006 8:32 am, Jonas Rosling wrote: > is there any easy why to check if a value is odd or not? $parity = $variable % 2 ? 'even' : 'odd'; echo "$variable is $parity\n"; -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL question
Thanks guys, I knew it was a stupid Q when I sent it, but I had another one where I encapsulated them in () blow up on me, so I figured if I asked and it was the same answer then I was on the right track. And so far all the tests have shown positive. :) Wolf > More of a MySQL question, but easily enough answered; > > Always group the OR with parenthese and the AND individually. Write the > query and test with MySQL before placing into PHP code; > > SELECT * FROM `table` > WHERE (`foo` = 'bar' >OR `foo` = 'glorp' >OR `sqirk` = 'glorp') > AND `today` = CURDATE() > AND `userID` = 'Marvin' > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If value is odd or not
Richard Lynch wrote: On Fri, June 2, 2006 8:32 am, Jonas Rosling wrote: is there any easy why to check if a value is odd or not? $parity = $variable % 2 ? 'even' : 'odd'; echo "$variable is $parity\n"; Let's make it even more compact and confusing :) echo "$variable is ".($variable % 2 ?'even':'odd')."\n"; I'm not sure if you can nuke the whitespace in the modulus area or not. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
This is just one of those cases where the designers had to make a judgement call on how things were going to operate. It makes sense if you look at the two things separately (incrementing vs string 'greatness' evaluation) and makes sense that how they chose to implement the functions are two valid choices among many ways that it could have been handled. >From a developers point of view it becomes "it is what it is". Now >understanding the nature of the beast we must accept that this is just how PHP >works. It's not wrong, it's just strange when it comes to z++ combined with a >for loop. Probably an unforeseen disconnect when designing PHP but the most >important thing is understanding HOW it works (more so than 'why' it was >designed that way) and coding accordingly. There are many other ways to accomplish an A-Z sequence so as long as what's been discussed is understood as "just how PHP is", and that it's logical for certain purposes, then we can choose one of the other choices for solving the problem. -TG = = = Original message = = = -TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to other languages, I just tried it on a lark just to see what would happen. Okay, so I found out it's limitations and quirks. But, you must admit that it is confusing to have a loop that goes from "a" to "z" and considers "aa" but not "aaa". Now, if the loop just went from a to z, then I would think that would be logical. But I fail to see the logic behind considering "aa" but not "aaa" in the evaluation. But then again, I'm not that informed. Enough said. tedd ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/Mysql: Making binary field available for download - extra browser window ?
On Fri, June 2, 2006 12:59 am, Matthew Pegg wrote: > Working on a PHP script at the moment where I want to be able to > extract a file (PDF file) from a mysql database\ That's bad. Read the archives. > and force the popup > of the File Download dialog, to allow the user to either save or open > the document (ie. and bypass loading the file using the browser's > plugin) Any browser that does't do a download prompt for that is severely broken. Forget the content-disposition crap. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extended Ascii Characters
On Thu, June 1, 2006 6:46 pm, Richard Luckhurst wrote: > Hi All > > I am in the process of cleaning up an application that was left half > finished. I > am fairly new to PHP so I am seeking the wisdom of the community to > help with a > little problem. > > In many cases I need to build command strings to be sent to a backend > system. > The strings have to contain a couple of non ascii characters. > > I have no problem with the following in a script > > $RM="\xFF"; $RM = chr(0xFF); -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables on Windows
Does some well-known problem exist with the session variables in Windows servers? Because in a system that I have running on a Windows server, sometimes the session variables are null causing errors, then I close the browser and open it and in the next intent everything works well... I can't understand why... The same system in a Linux server runs well always ¿? Ahead of time, thank you very much, Tom. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
2006/6/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: This is just one of those cases where the designers had to make a judgement call on how things were going to operate. It makes sense if you look at the two things separately (incrementing vs string 'greatness' evaluation) and makes sense that how they chose to implement the functions are two valid choices among many ways that it could have been handled. How does it make sense? I don't understand your argument, can you explain it a little bit more? From a developers point of view it becomes "it is what it is". Now understanding the nature of the beast we must accept that this is just how PHP works. It's not wrong, it's just strange when it comes to z++ combined with a for loop. Probably an unforeseen disconnect when designing PHP but the most important thing is understanding HOW it works (more so than 'why' it was designed that way) and coding accordingly. I agree, this is what we have and what we asked for, we wanted to use strings on a math context and these things are bound to happen. But still saying that something is right/wrong/not right/not wrong in CS is a bold statement. On a certain context something may seem right but when the context changes it turns out to be wrong, for example suppose we have a programming language that handles strings the way PHP does, and it implements templates or generics (the term you prefer the most). The template/generic should have to be aware of strings when using math operators, because they don't behave the way a math literal would. There are many other ways to accomplish an A-Z sequence so as long as what's been discussed is understood as "just how PHP is", and that it's logical for certain purposes, then we can choose one of the other choices for solving the problem. I don't think it's only about us as developers using PHP, but us as community giving back something to the community. This might be a small issue but what would be the whole point of being an open-source community if we can't at least discuss about it? "It just the way things are" is not an argument, it's an excuse. -TG
Re: [PHP] When is "z" != "z" ?
On Monday 05 June 2006 14:56, Martin Alterisio wrote: > 2006/6/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > This is just one of those cases where the designers had to make a > > judgement call on how things were going to operate. It makes sense if > > you look at the two things separately (incrementing vs string 'greatness' > > evaluation) and makes sense that how they chose to implement the > > functions are two valid choices among many ways that it could have been > > handled. > > How does it make sense? I don't understand your argument, can you explain > it a little bit more? See Robert Cummings' post. < and > are being interpreted in this case for alphabetical order. Read "<" as "alphabetically before", and <= as "alphabetically before or string-equal to". Is a alphabetically before or string-equal to z? TRUE. Is b alphabetically before or string-equal to z? TRUE. ... Is z alphabetically before or string-equal to z? TRUE. (string-equal) Is aa alphabetically before or string-equal to z? TRUE. (a < z alphabetically, the second character is never checked). Is ab alphabetically before or string-equal to z? TRUE. ... Is yz alphabetically before or string-equal to z? TRUE. Is za alphabetically before or string-equal to z? FALSE. (a alphabetically after NULL character. Bob is alphabetically before Bobby for the same reason.) See how the comparison works? It's a purely alphabetic comparison. As for the increment, it actually would never have occurred to me to ++ a string before this thread, honestly. :-) However, what it appears to be doing (and I'm sure Rasmus will correct me if I'm wrong) is using a "string base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls over" to the next "digit" (which because it's a string goes to the right rather than the left), and resets. So just as 9++ rolls over to 10, z rolls over to aa. Does that make more sense? -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
At 1:10 PM -0400 6/5/06, Robert Cummings wrote: >NO! More must be said!! > >a <= z >b <= z >c <= z >-snip- >yx <= z >yy <= z >yz <= z >za > z > >Sooo, the comparisons stop before we get to aaa >and so aaa is never reached. za is the last comparison to occur at which >point the test fails and the loop stops. > >Cheers, >Rob. Rob: Okay, I tried to get out of it, but I guess more must be said. I do understand why the loop stops -- I totally understand the mechanics. After all this, how could I not? Besides, it's really not that difficult, is it? So, what might you guess I'm really talking about? You see, what is failing to be understood here is what I'm addressing, which is basic set theory. One of the basic foundations for mathematics If I have a set that is defined as all elements > "whatever" and < "something else", then you can address the set. You can ask questions about the set, such as what's the population of the set -- besides itself, does the set have any subsets, and such -- get the idea? Now, if you have a set [A] where all elements within are defined as ("a" or greater) and (less than "z") -- then, believe or not, that set is infinite -- as is the set for everything > "z". If you choose, which is the case here, to consider only a subset of [A], then that's fine -- but understand that when you say the sequence is -- a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab -- it's not! But rather, the actual sequence is: a b c ... x y z aa ab ac ... yx yy yz aaa aab aac... z You simply have chosen to arbitrarily end the sequence at "yz". That's the reason why "aaa" is less than "z" but not included in the "php-loop" set of (for i=a to z). You can't say that "a" and "aaa" are members of a set identified as < "z" and then step through all the members of that population (an infinite group) and not include "aaa" -- UNLESS -- you arbitrarily determine an end point for a much smaller sub-set. Now, unless, there is something that I don't see, which certainly could be the case, then php designers could have just as easily ended the loop at "z" and dispensed with this quirk all together. Besides, what's the point of having 676 character between a and z? Is there one? I think the "accepted" number would be closer to 26, don't you think? It just seems more like common sense to me -- doesn't it to you? But this is the way it is and I except that -- but as Dirty Harry once said "A man's got to know his limitations" -- this not only applies to men and programmers, but also for languages as well. For example, the Unicode issue was raised during this discussion -- if php doesn't consider the numeric relationship of characters, then I see a big problem waiting in the wings. Because if we're having these types of discussions with just considering 00-7F characters, then I can only guess at what's going to happen when we start considering 00-FF code-points. Now, was that enough said? :-) Cheers. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
tedd wrote: For example, the Unicode issue was raised during this discussion -- if php doesn't consider the numeric relationship of characters, then I see a big problem waiting in the wings. Because if we're having these types of discussions with just considering 00-7F characters, then I can only guess at what's going to happen when we start considering 00-FF code-points. Now, was that enough said? :-) I don't think you really understand this. < and > are collation operators when they operate on strings. They have absolutely nothing to do with the numeric values of the characters. It just so happens that in English iso-8859-1 there is a 1:1 relationship between the numeric values and the collation order, but you can think of that as dumb luck. To better understand this, I suggest you start reading here: http://icu.sourceforge.net/userguide/Collate_Intro.html Note one of the points on that page. That in Lithuanian 'y' falls between 'i' and 'k'. So even without going into Unicode and just using low-ascii, you have these issues. Now, until we get to PHP 6, we don't have decent Unicode support and we don't have LOCALE-aware operators. You will have to manually use strcoll() to get them, but that is going to change and you will have the ICU collation algorithms available and for Unicode strings it will be automatic. You can still have binary-strings if you don't want locale-aware collation, of course. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
On Mon, 2006-06-05 at 21:35, tedd wrote: > At 1:10 PM -0400 6/5/06, Robert Cummings wrote: > >NO! More must be said!! > > > >a <= z > >b <= z > >c <= z > >-snip- > >yx <= z > >yy <= z > >yz <= z > >za > z > > > >Sooo, the comparisons stop before we get to aaa > >and so aaa is never reached. za is the last comparison to occur at which > >point the test fails and the loop stops. > > > >Cheers, > >Rob. > > > Rob: > > Okay, I tried to get out of it, but I guess more must be said. > > I do understand why the loop stops -- I totally understand the mechanics. > After all this, how could I not? Besides, it's really not that difficult, is > it? So, what might you guess I'm really talking about? > > You see, what is failing to be understood here is what I'm addressing, which > is basic set theory. One of the basic foundations for mathematics > > If I have a set that is defined as all elements > "whatever" and < "something > else", then you can address the set. You can ask questions about the set, > such as what's the population of the set -- besides itself, does the set have > any subsets, and such -- get the idea? > > Now, if you have a set [A] where all elements within are defined as ("a" or > greater) and (less than "z") -- then, believe or not, that set is infinite -- > as is the set for everything > "z". > > If you choose, which is the case here, to consider only a subset of [A], then > that's fine -- but understand that when you say the sequence is -- > > a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab > > -- it's not! > > But rather, the actual sequence is: > > a b c ... x y z aa ab ac ... yx yy yz aaa aab aac... z > > You simply have chosen to arbitrarily end the sequence at "yz". That's the > reason why "aaa" is less than "z" but not included in the "php-loop" set of > (for i=a to z). > > You can't say that "a" and "aaa" are members of a set identified as < "z" and > then step through all the members of that population (an infinite group) and > not include "aaa" -- UNLESS -- you arbitrarily determine an end point for a > much smaller sub-set. > > Now, unless, there is something that I don't see, which certainly could be > the case, then php designers could have just as easily ended the loop at "z" > and dispensed with this quirk all together. > > Besides, what's the point of having 676 character between a and z? Is there > one? I think the "accepted" number would be closer to 26, don't you think? It > just seems more like common sense to me -- doesn't it to you? > > But this is the way it is and I except that -- but as Dirty Harry once said > "A man's got to know his limitations" -- this not only applies to men and > programmers, but also for languages as well. > > For example, the Unicode issue was raised during this discussion -- if php > doesn't consider the numeric relationship of characters, then I see a big > problem waiting in the wings. Because if we're having these types of > discussions with just considering 00-7F characters, then I can only guess at > what's going to happen when we start considering 00-FF code-points. > > Now, was that enough said? :-) ABSOLUTELY NOT! *bahahahahah* You gotta stop smoking the ganja Tedd, it's slowing your synapses. No there are not 676 character combinations less than z. There are an infinite number. a, aa, aaa, , a, a, ... ab, aab, aaab, b, ..., . You are incrementing, this follows rules of incrementation and so incrementing +1 at a time as defined for strings in PHP causes you to only see 676 of the combinations less than z. It's like having 1.0 and incrementing it .5 each time, and saying WTF, why are there only 19 entries less than or equal to 10? There aren't, there are an infinite number of values between 1.0 and 10 but we the rule sof incrementation in this case skip past them. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
At 8:18 PM -0500 6/5/06, Larry Garfield wrote: >See how the comparison works? It's a purely alphabetic comparison. > >As for the increment, it actually would never have occurred to me to ++ a >string before this thread, honestly. :-) However, what it appears to be >doing (and I'm sure Rasmus will correct me if I'm wrong) is using a "string >base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls over" >to the next "digit" (which because it's a string goes to the right rather >than the left), and resets. So just as 9++ rolls over to 10, z rolls over to >aa. > >Does that make more sense? Maybe to you, but not me. In my book, you can't add a positive value to z and produce something that is less than z. For example, "aa" is not greater than "z" -- is it? Besides, what "value" are we adding? There is no incremental "character" in strings and adding two characters doesn't evaluate to anything. In my last post I showed an "actual sequence" which is debatable. It could be interpreted that the infinite set starts at "a, aa, aaa,... " and never reaches "b". Oddly enough, this could be viewed in all sorts of ways. It's probably best if we don't look at characters as numbers. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
2006/6/5, Larry Garfield <[EMAIL PROTECTED]>: On Monday 05 June 2006 14:56, Martin Alterisio wrote: > 2006/6/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > This is just one of those cases where the designers had to make a > > judgement call on how things were going to operate. It makes sense if > > you look at the two things separately (incrementing vs string 'greatness' > > evaluation) and makes sense that how they chose to implement the > > functions are two valid choices among many ways that it could have been > > handled. > > How does it make sense? I don't understand your argument, can you explain > it a little bit more? See Robert Cummings' post. < and > are being interpreted in this case for alphabetical order. Read "<" as "alphabetically before", and <= as "alphabetically before or string-equal to". Is a alphabetically before or string-equal to z? TRUE. Is b alphabetically before or string-equal to z? TRUE. ... Is z alphabetically before or string-equal to z? TRUE. (string-equal) Is aa alphabetically before or string-equal to z? TRUE. (a < z alphabetically, the second character is never checked). Is ab alphabetically before or string-equal to z? TRUE. ... Is yz alphabetically before or string-equal to z? TRUE. Is za alphabetically before or string-equal to z? FALSE. (a alphabetically after NULL character. Bob is alphabetically before Bobby for the same reason.) See how the comparison works? It's a purely alphabetic comparison. As for the increment, it actually would never have occurred to me to ++ a string before this thread, honestly. :-) However, what it appears to be doing (and I'm sure Rasmus will correct me if I'm wrong) is using a "string base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls over" to the next "digit" (which because it's a string goes to the right rather than the left), and resets. So just as 9++ rolls over to 10, z rolls over to aa. Does that make more sense? You misunderstood me, I completely understand how the operators function, but you're saying it makes sense the way their functionality is assigned, what I want to know is the reasons you have that support those affirmations. I completely understand that string comparison is done alphabetically, but how does having the functionality for the ++ operator create a sequence that are inconsistent with the comparison operator, makes sense?
Re: [PHP] When is "z" != "z" ?
On Mon, 2006-06-05 at 22:00, tedd wrote: > At 8:18 PM -0500 6/5/06, Larry Garfield wrote: > >See how the comparison works? It's a purely alphabetic comparison. > > > >As for the increment, it actually would never have occurred to me to ++ a > >string before this thread, honestly. :-) However, what it appears to be > >doing (and I'm sure Rasmus will correct me if I'm wrong) is using a "string > >base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls over" > >to the next "digit" (which because it's a string goes to the right rather > >than the left), and resets. So just as 9++ rolls over to 10, z rolls over to > >aa. > > > >Does that make more sense? > > Maybe to you, but not me. > > In my book, you can't add a positive value to z and produce something that is > less than z. > > For example, "aa" is not greater than "z" -- is it? If I remember my abstract algebra correctly, the modulus operator forms a set for any given value right operand. Interestingly then taking the set of x%10 we find that adding 1 to x when x is 9 is indeed less than 9. I'm sure I could summarize this better if I could remember my abstract algebra and spaces *lol*. I remember vaguely proving spaces and stuff based on various properties. Either way the above exmaple gives a simple case where your assertion also fails, and this is in the world of general mathematics. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
On Monday 05 June 2006 21:12, Martin Alterisio wrote: > > As for the increment, it actually would never have occurred to me to ++ a > > string before this thread, honestly. :-) However, what it appears to be > > doing (and I'm sure Rasmus will correct me if I'm wrong) is using a > > "string > > base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls > > over" > > to the next "digit" (which because it's a string goes to the right rather > > than the left), and resets. So just as 9++ rolls over to 10, z rolls > > over to > > aa. > > > > Does that make more sense? > > You misunderstood me, I completely understand how the operators function, > but you're saying it makes sense the way their functionality is assigned, > what I want to know is the reasons you have that support those > affirmations. I completely understand that string comparison is done > alphabetically, but how does having the functionality for the ++ operator > create a sequence that are inconsistent with the comparison operator, makes > sense? Because defining ++ and < and > in such a way as to make them "behave like numbers" would have made them not work for alphabetizing. A string is a string, and comparison of strings is alphabetic (for some definition of alphabet). It's more useful to deal with strings as strings than to make them quack like numbers. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
2006/6/6, Larry Garfield <[EMAIL PROTECTED]>: On Monday 05 June 2006 21:12, Martin Alterisio wrote: > > As for the increment, it actually would never have occurred to me to ++ a > > string before this thread, honestly. :-) However, what it appears to be > > doing (and I'm sure Rasmus will correct me if I'm wrong) is using a > > "string > > base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls > > over" > > to the next "digit" (which because it's a string goes to the right rather > > than the left), and resets. So just as 9++ rolls over to 10, z rolls > > over to > > aa. > > > > Does that make more sense? > > You misunderstood me, I completely understand how the operators function, > but you're saying it makes sense the way their functionality is assigned, > what I want to know is the reasons you have that support those > affirmations. I completely understand that string comparison is done > alphabetically, but how does having the functionality for the ++ operator > create a sequence that are inconsistent with the comparison operator, makes > sense? Because defining ++ and < and > in such a way as to make them "behave like numbers" would have made them not work for alphabetizing. A string is a string, and comparison of strings is alphabetic (for some definition of alphabet). It's more useful to deal with strings as strings than to make them quack like numbers. Then, if it's not a math operation, why use a math operator for such functionality? In which way is the ++ operator that generates a string sequence, useful enough to justify the formal inconsistency between the math operators? I still don't see the advantages of having the ++ recognize the string as a sequence, and generate the next item in the sequence. I believe those decisions should be left to the coder, because he knows what the string really represents and which kind of sequence is being used.
[PHP] String Manipulation
Hi guys I have the following intention and would really like to know if tis possible and if its possible how should it be done. I have a string that is something like this: "1. Prologue2. First days3. Drastic choice4. Sowarocs5. Training6. Teneb" How can I retrieve the Values and assign it to a variable, and next retrieve the name and assign it to another variable and so on... I'd like to get something like: 1 1. Prologue 2 2. First days 3 3. Drastic choice 4 4. Sowarocs 5 5. Training 6 6. Teneb and eacch of these should be in a variable, remembering that the number of variables is dynamic so it can be only one or 100. Thanks guys, Rodrigo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String Manipulation
Rodrigo de Oliveira Costa wrote: Hi guys I have the following intention and would really like to know if tis possible and if its possible how should it be done. I have a string that is something like this: "1. Prologue2. First days3. Drastic choice4. Sowarocs5. Training6. Teneb" How can I retrieve the Values and assign it to a variable, and next retrieve the name and assign it to another variable and so on... Didn't you ask this a few days ago? I gave you an answer: http://marc.theaimsgroup.com/?l=php-general&m=114923129030154&w=2 -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is "z" != "z" ?
On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote: > > Because defining ++ and < and > in such a way as to make them "behave like > > numbers" would have made them not work for alphabetizing. A string is a > > string, and comparison of strings is alphabetic (for some definition of > > alphabet). It's more useful to deal with strings as strings than to make > > them quack like numbers. > > > > Then, if it's not a math operation, why use a math operator for such > functionality? In which way is the ++ operator that generates a string I don't ever remember seeing ++ in math class. I do remember seeing it in lots of computer classes and to that end it was "just an operator" with whatever semantic meaning was applied to it for a given language. I guess it's usually to increment an integer, but that's just "in general". I mean if we want to get into "math" operators being used for string purposes, then we should look at how many languages use the "+" operator to concatenate two strings -- by your accounts they should treat their operands as integers and do a rote addition. > sequence, useful enough to justify the formal inconsistency between the math > operators? I still don't see the advantages of having the ++ recognize the > string as a sequence, and generate the next item in the sequence. I believe > those decisions should be left to the coder, because he knows what the > string really represents and which kind of sequence is being used. In C++ they do leave it to the coder, and well, we all know what a mess it can be deciphering overloaded operators in C++ (or maybe we ALL don't). At any rate, the PHP overlords made a choice, and IMHO the best choice. For such a fringe issue I don't see what the argument is all about. If you want the functionality you get in C by incrementing a char, then use the chr() function on an integer. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php