[PHP] PHP5 DOM
Hi to all. I have a problem. I need to glue 2 or more DomDocument? objects to one. After hours of hard coding I've came to the conclusion that there is no possibility to use PHP 5.3.0 to realize it. Is there anybody who could break this conclusion and give me an appropriate solution? P.S. I did it with PHP 5.1.0 cvs version and I used a small trick. Thanks. -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 DOM
Sorry. There is a mistake. Hi to all. I have a problem. I need to glue 2 or more DomDocument? objects to one. After hours of hard coding I've came to the conclusion that there is no possibility to use PHP 5.0.3 to realize it. Is there anybody who could break this conclusion and give me an appropriate solution? P.S. I did it with PHP 5.1.0 cvs version and I used a small trick. Thanks. -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 DOM
On Tue, 22 Feb 2005 06:58:12 -0500 Yann Larrivee [EMAIL PROTECTED] wrote: Hi Sergio maybe you should have a look at importNode http://ca3.php.net/manual/en/function.dom-domdocument-importnode.php I've been tried to use this function. There are no results. This function (as well as appendChild() ) requires parameter of DOMNode type. But root element of DOMDocument object is DOMElement. Any attempt to use it as DOMNode (while it is successor of DOMNode) becomes as fail. No errors. No results. Nothing. Sample code: ?php $dom = new DomDocument(); $dom-appendChild(($root = $dom-createElement(test1))); $dom2 = new DomDocument(); $dom2-appendChild(($root2 = $dom2-createElement(test2))); $dom-importNode($dom2-childNodes-item(0)); var_dump($dom-saveXML()); ? Result is: string(31) ?xml version=1.0? test1/ I beleive this is what you need along with Normalize. Good luck. Yann On Tuesday 22 February 2005 06:54, Sergio Gorelyshev wrote: Hi to all. I have a problem. I need to glue 2 or more DomDocument? objects to one. After hours of hard coding I've came to the conclusion that there is no possibility to use PHP 5.3.0 to realize it. Is there anybody who could break this conclusion and give me an appropriate solution? P.S. I did it with PHP 5.1.0 cvs version and I used a small trick. Thanks. -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 DOM
On Tue, 22 Feb 2005 15:02:38 +0200 Sergio Gorelyshev [EMAIL PROTECTED] wrote: It's work!!! :-) Thanks. Here is a valid code: ?php $dom = new DomDocument(); $dom-appendChild(($root = $dom-createElement(test1))); $dom2 = new DomDocument(); $dom2-appendChild(($root2 = $dom2-createElement(test2))); $dom-appendChild($dom-importNode($dom2-childNodes-item(0)); var_dump($dom-saveXML()); ? The result is: string(40) ?xml version=1.0? test1/ test2/ On Tue, 22 Feb 2005 06:58:12 -0500 Yann Larrivee [EMAIL PROTECTED] wrote: Hi Sergio maybe you should have a look at importNode http://ca3.php.net/manual/en/function.dom-domdocument-importnode.php I've been tried to use this function. There are no results. This function (as well as appendChild() ) requires parameter of DOMNode type. But root element of DOMDocument object is DOMElement. Any attempt to use it as DOMNode (while it is successor of DOMNode) becomes as fail. No errors. No results. Nothing. Sample code: ?php $dom = new DomDocument(); $dom-appendChild(($root = $dom-createElement(test1))); $dom2 = new DomDocument(); $dom2-appendChild(($root2 = $dom2-createElement(test2))); $dom-importNode($dom2-childNodes-item(0)); var_dump($dom-saveXML()); ? Result is: string(31) ?xml version=1.0? test1/ I beleive this is what you need along with Normalize. Good luck. Yann On Tuesday 22 February 2005 06:54, Sergio Gorelyshev wrote: Hi to all. I have a problem. I need to glue 2 or more DomDocument? objects to one. After hours of hard coding I've came to the conclusion that there is no possibility to use PHP 5.3.0 to realize it. Is there anybody who could break this conclusion and give me an appropriate solution? P.S. I did it with PHP 5.1.0 cvs version and I used a small trick. Thanks. -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] round
On Wed, 26 Jan 2005 06:32:32 -0500 blackwater dev [EMAIL PROTECTED] wrote: Hello, I have these values: 8.26456 9.7654 3. 5.2689 and I want them rounded to two decimal places so I use the round : round($value,2) which gives me, for example: 8.26 You can try the sprintf() function But, it also gives me 3 instead of 3.00. How can I round but retain the 0's? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php 5.1.0 release - when?
Hello all. Is anyone aware of php 5.1.0 release date? Thanks. -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 5 interfaces
On Thu, 20 Jan 2005 11:13:11 -0800 (PST) Richard Lynch [EMAIL PROTECTED] wrote: Sergio Gorelyshev wrote: Hi all. Situation: interface MyInterface { public static myMethod(); } class MyClass implements MyInterface { public static myMethod() {} } This sample will crash with message Fatal error: Access type for interface method MyInterface::myMethod() must be omitted in somefile.php on line NN Why I'm not able to clarify call's type (static) for methods in interface? I'm predict closely that method myMethod() in all classes which implements MyInterface must be called statically. A little trick allowed to me to resolve this problem, but my question more ideological than practical. As I understand it, an 'interface' is, by definition, never gonna have an actualy object instantiated. Thus, there can never *BE* an object for which private/public/protected have any meaning. You can only use the private/public/protected on the 'class' definitions. Thanks to all. First sample of interface usage in php manual: ?php interface ITemplate { public function setVariable($name, $var); public function getHtml($template); } class Template implements ITemplate { private $vars = array(); public function setVariable($name, $var) { $this-vars[$name] = $var; } public function getHtml($template) { foreach($this-vars as $name = $value) { $template = str_replace('{'.$name.'}', $value, $template); } return $template; } } ? IMHO its normally to use access type for methods declaration in interfaces. Why not? Maybe my first example was not sufficiently illustrative. But my question was why it does not work in one environment and work fine in another. The problem has acquired when i try to add static in my interface definition. I don't think that this is a bug in PHP. I just want to be deep insight in OOP of PHP5 engine. Even if you *KNOW* that all class definitions *should* for this to be 'public' it just doesn't make sense from the strictly technical stand-point of what an 'interface' is to declare it there. Maybe somewhere over on php-dev you could make the case for the PHP Dev Team to implement something good/interesting when public/protected/private is used there, but currently it's semanticly undefined to have it there, so it can't be there. Disclaimer: I could easily be 100% wrong in this entire post. :-) -- Like Music? http://l-i-e.com/artists.htm -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [Fwd: Re: [PHP] php 5 interfaces]
On Fri, 21 Jan 2005 11:56:55 +0100 Jochem Maas [EMAIL PROTECTED] wrote: Tbird switched the reply and reply-all buttons again ;-)... ? IMHO its normally to use access type for methods declaration in interfaces. Why not? Maybe my first example was not sufficiently illustrative. But my question was why it does not work in one environment and work fine in another. it worked for a while because it was originally overlooked, then they 'fixed' it. -- you may not agree with the devs. The problem has acquired when i try to add static in my interface definition. I don't think that this is a bug in PHP. I just want to be deep insight in OOP of PHP5 engine. your right, its not a bug - although some have argued that its Sucks(tm). in short it was decided by the devs that interfaces are not meant for static classes, they only apply to objects - which is why 'static' is not (no longer) allowed on interface methods. if you want to know more then digging into the php internals mailing list archives will give you long discussions and justifications as to why it works they way it does. if you think about it you can see where they are coming from: passing around classes (i.e. classNames) and then checking whether said class implements something is really odd, instead you pass around objects. or more simply: class == blueprint object == house you can interface with a house (lets hope your house IMPLEMENTS a door interface!) but you can't interface with a blueprint (possibly with the piece of paper it may be printed on but not with the actual blueprint) because the blueprint is an idea/concept. hope that helps you to understand the rationale. Thanks. This really helped me to understand php developer's way of thinking. rgds, JOchem ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if then else short form
On Fri, 21 Jan 2005 12:01:09 + Ben Edwards [EMAIL PROTECTED] wrote: I seem to remember seing someone use a abreaviated form of a if/them/else of the type that can be used in java. It was something like if ( a=b ) ? a=1 ; a=2; Anybody know what the correct syntax is? condition ? do_that_if_true : do_that_if_false; Ben -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php 5 interfaces
Hi all. Situation: interface MyInterface { public static myMethod(); } class MyClass implements MyInterface { public static myMethod() {} } This sample will crash with message Fatal error: Access type for interface method MyInterface::myMethod() must be omitted in somefile.php on line NN Why I'm not able to clarify call's type (static) for methods in interface? I'm predict closely that method myMethod() in all classes which implements MyInterface must be called statically. A little trick allowed to me to resolve this problem, but my question more ideological than practical. Thanks -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Use a query twice
On Thu, 20 Jan 2005 13:06:54 - Shaun [EMAIL PROTECTED] wrote: Hi, I have the following query: $result = mysql_query(SELECT * FROM Users); while( $r = db_fetch_array( $result ) ){ echo $r['Name']; } Is it possible to use the same result set to loop through the values form the begining or do I have to create the $result varible again? see mysql_data_seek() Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php 5 interfaces
On Thu, 20 Jan 2005 16:39:21 +0100 M. Sokolewicz [EMAIL PROTECTED] wrote: Sergio Gorelyshev wrote: Hi all. Situation: interface MyInterface { public static myMethod(); } class MyClass implements MyInterface { public static myMethod() {} } This sample will crash with message Fatal error: Access type for interface method MyInterface::myMethod() must be omitted in somefile.php on line NN Why I'm not able to clarify call's type (static) for methods in interface? I'm predict closely that method myMethod() in all classes which implements MyInterface must be called statically. A little trick allowed to me to resolve this problem, but my question more ideological than practical. Thanks it's not the static part, it's the public part. You can't make non-public static methods. It's simply impossible by the definition of protected and private (both allow only the object itself to access it, or (in case of protected) a descendent). So, removing the public part should work out fine. I'm confused. Construction like that: ?php interface MyInterface { public static function myMethod(); } class MyClass implements MyInterface { public static function myMethod() {} } MyClass::myMethod(); ? fork fine when i'm fetched it from my framework. But it's crashes inside framework with previous message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- RE5PECT Sergio Gorelyshev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php