yeh please explian. my only true problem with php is that it doens't have true data encapsulation with its default classes butif you use smarty all that criss and you dont have to worry bout a thing. suh what you talking bout.
yeh please explian. my only true problem with php is that it doens't have true data encapsulation with its default classes butif you use smarty all that criss and you dont have to worry bout a thing. suh what you talking bout.
I recently did some PHP work and had the frustrating experience of trying to work within the limitations of the available datatypes.
Please correct me if I'm wrong. PHP is all about arrays and associative arrays.
In order to find out if an associative array contained a key the code was like:
note the extra functions required:Code:<?php $peterpiper = array(); $stuffofpeter = array(); $peterpiper['had'] = $stuffofpeter; array_push($peterpiper['had'],'peck','of pickled peppers'); if (array_key_exists('had',$peterpiper)){ echo "peter piper picked a " . $peterpiper['had'][0] . " of " . $peterpiper['had'][1]; } foreach ($peterpiper['had'] as $peter_piper) { if ($peter_piper == 'of pickled peppers'){ echo "<hr>if peter piper picked a peck $peter_piper,"; echo "<hr>where's the peck $peter_piper, peter piper picked?"; } } ?>
array_push() and array_key_exists()
This is typical of php, lots of extra functions.
I don't like needing to research new functions because the language doesn't support what I want to do out of the box.
To be fair it's easy to google for the code you need.
here's the python version
Learn more from python programmers at the Jamaica Python Users Mailing List http://python.zope.com.jm/subscribeCode:peterpiper={} peterpiper['had']=['peck','of pickled peppers'] if peterpiper['had']: print "peter piper picked a " + peterpiper['had'][0] + \ " of " + peterpiper['had'][1] for peter_piper in peterpiper['had']: if 'of pickled peppers' in peter_piper: print "<hr>if peter piper picked a peck " + peter_piper print "<hr>where's the peck " + peter_piper + \ " ,peter piper picked?"
Last edited by pigeonflight; Jun 22, 2006 at 08:33 AM.
Zope, Linux, Web, Intranet
www.plone.org
Lame! The problem is you don't know enough about PHP you recomend or even compare it to anything. The extra array functions are necessary in order to allow you to WRITE BETTER PROGRAMS. You need better examples to prove your point. More functions allow for programming freedom. There is no one way to do anything.
Basically the 2 pieces of code that you posted are identical. Even though the php one is more readable.
You need to learn more PHP. Register at my site and look at the source code.Code:<?php $peterpiper = array(); $peterpiper['had']= array('peck','of pickled peppers'); if ( isset($peterpiper['had']) ) if( is_array($peterpiper['had']) ){ echo "peter piper picked a " . $peterpiper['had'][0] . " of " . $peterpiper['had'][1]; } foreach ($peterpiper['had'] as $key=>$value) { if ($value == 'of pickled peppers'){ echo "<hr>if peter piper picked a peck $value,"; echo "<hr>where's the peck $value, peter piper picked?"; } } ?>
Learn more from python programmers at the Jamaica Python Users Mailing List http://python.zope.com.jm/subscribe
Check out My Awesome Blog & News Jamaica
i just love that look that zope sites have. wish i took plone and zope more serious when the frame work was just released.
as of late i'm only interested in frameworks cause i'm sick of the age old method of development (ground up design). also i hate the crud ops.. (creation retrieval updating and deletion) by far the most repetitive type of code i find my self doing. turbo gears, which is python based, prado (php based object oriented framework ) everybody done know bout the popular ruby on rails, there's django (which runs on pythong as well)
and something that caught my eye th4e other day. open laszlo it sorta seems like an open sourcce implementation of macromedia's flex... frameworks ar our future (programers)
Perhaps I should start again.Originally Posted by owen
1. The reason I used arrays was in order to WRITE A BETTER PHP PROGRAM, I am thankful that PHP HAS arrays.
2. I found it akward to work with arrays when compared to working with dictionaries (comparable to associative arrays),lists(comparable to arrays) and tuples (not sure what to compare this to) in Python.
I have found the data structures in python simpler to manipulate. Again, please correct me if I'm wrong about this.
Your version of the code does clear up a few things, for example, I didn't need to assign the second array to a variable silly me.
BTW... what's Lame about my assessment?
Zope, Linux, Web, Intranet
www.plone.org
there is this data structure called a "pointer". Its lame because you complaining about minor differences in data structure names. A dictionaries = lists = tuples = pointers = strings = integers its all symantics. Some people just like their chicken fried and some people like eggs.Originally Posted by pigeonflight
Check out My Awesome Blog & News Jamaica
python and php sux!
dont answer that...
Cultured in Aggression and Koding like a Warrior!!
“Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
"The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein