[PHP] empty function and array indices
Hello! Suppose I have the following code: $a = array('a'=1, 'b'=2); echo empty($a['c'])?'empty':'not empty'; echo $a['c']; Why doesn't the 2nd line output a warning when error_reporting is set to E_ALL? Is empty() some kind of special function where the validity of indices is not checked? If that is the case, I have two questions: 1. Will this behavior persist in future versions of PHP? 2. Are there other functions or a general rule where PHP doesn't output warnings when a nonexistant index is given? -- Immanuel doesn't pun, he Kant. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] References and array indexes
Hello! The following PHP code: ? $a = array(1=First Element, 2=Second Element); $v = $a['3']; print_r($a); ? has this result: Array( 1 = First Element, 2 = Second Element, 3 = ) Can anyone give me an explanation for this? What is happening in the guts of the PHP interpreter when it gets these instructions? With best regards Gabriel Birke -- KONTOR4_Neue Medien Plathnerstraße 5 30175 Hannover Fax: +49 51184 48 98 99 mailto:[EMAIL PROTECTED] http://www.kontor4.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What do I need in order to do the following with php.
I want to make sure I'm correct in doing something. What do I need in order to perform the following: - Send an XML message to something at a website, have it load a database with the message, and return an acknowledgement. --- SOAP? Google - XML SOAP If SOAP seems too complicated for your purposes, you can also have a look at XML-RPC: http://www.xmlrpc.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP, Classes, Sharing Code
Hello! Another option would be to have a generic List class that displays items in a list. Both your Album and Photo class should implement a method like getNextItem or the PHP5-native iterator methods so the List class can iterate over a class assigned to it without knowing what it is. If the properties of Album and Photo are too different to generate a list, you could make a generic list class and subclass it for Album and Photo. If you want to know more about OOP, I recommend this book: http://www.amazon.com/exec/obidos/tg/detail/-/0201715945/ qid=1088493890/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-6243709-1202536? v=glances=booksn=507846 It helped me a great deal understanding how to think object oriented. A third option would be to use the Smarty templating system. With templates you would only have to write a small portion of HTML code for each list. With best regards Gabriel Birke -- KONTOR4_Neue Medien Plathnerstraße 5 30175 Hannover Fax: +49 51184 48 98 99 mailto:[EMAIL PROTECTED] http://www.kontor4.de Am 28.06.2004 um 20:32 schrieb Joel Kitching: I'm kind of new to OOP, so bear with me here... I have a portfolio which contains albums. These albums contain photos. So it would be natural to declare the classes: Portfolio Album Photo It seems to me that none of these classes have the is a relationship, and therefore can not be extended from each other. The reason I wish to do this, is because listing albums and listing photos use almost exactly the same code. i.e. // The constructor would automatically fill in the album's variables from the database. $album = new Album($album_id); // This would print out the HTML for the list of photos. $album-list_photos(); ... or the same thing with Portfolio, which would list the albums. The only thing that's different is the links to which the anchors are pointing, and the content. (Thumbnails.) So my question is, should I just duplicate the code in each class (Portfolio and Album), or is there a better way of organizing all of this? -- Joel Kitching http://midgardmanga.keenspace.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing entities in XML attributes
Hello! I've got an XML file that has the following tag: customtext text=first linelt;br /gt;second line / I parse it with the following handler (simplified a bit): function start_tag($parser, $name, $attrs) { global $text; if($name == CUSTOMTEXT) $text = $attrs['TEXT']; // more tags here .. } When I echo $text in a HTML page, I see a linebreak - just as I intended. One of our customers has the script installed on his server and he doesn't see a linebreak but sees br / printed out. He has to write the tag like this: customtext text=first line br /second line / Now I've got two questions: 1. Which tag is correct XML? 2. What is the cause of this? I'm running the script with PHP 4.1.2 and EXPAT Version 1.95.2 Don't know what our customer has running. With best regards Gabriel Birke -- KONTOR4_Neue Medien Plathnerstraße 5 30175 Hannover Fax: +49 51184 48 98 99 mailto:[EMAIL PROTECTED] http://www.kontor4.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with creating an XML Document
I think you only have to change one line of your php code: $text = $doc-create_text_node(00); instead of $text = $doc-create_text_node($el[00]); With best regards Gabriel Birke -- KONTOR4_Neue Medien Plathnerstraße 5 30175 Hannover Fax: +49 51184 48 98 99 mailto:[EMAIL PROTECTED] http://www.kontor4.de Am 23.06.2004 um 16:18 schrieb Eric L. Sammons: Using PHP 4.3.2 I am trying to create an XML file that looks similar to the following: ?xml version=1.0 encoding=UTF-8? Server Name=pxtest01 Serical_Number0/Serical_Number Asset_Tag0/Asset_Tag ModelDL380/Model Location8th Floor/Location Cabinet2/Cabinet Application_GroupCustomer/Application_Group PurposeUpgrade/Purpose /server I get the following output: ?xml version=1.0? Server Name=pxtest01Serial_Number/Serial_Number/server Using the following code: ?php $doc = domxml_new_doc(1.0); $root = $doc-add_root(Server); $root-set_attribute(Name, pxtest01); $el = $doc-create_element(Serial_Number); $root-append_child($el); $text = $doc-create_text_node($el[00]); $el-append_child($text); print htmlentities($doc-dump_mem()); ? Can someone help me fix my code so that when I add an element I can also set some contents or a value for that element? example serial_number000/serial_number Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php