[PHP] php-general-unsubscr...@lists.php.net
-- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] syntax error in class
Hello guys, I encountered a syntax error, and cannot figure out the reason, for example: == CODE == 1:'str1'.'str2'); 3:?> === Works fine, but when I try to put it into a class, say: == CODE == 1:'str1'.'str2'); 5:} 6:?> == OUTPUT == Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 PHP Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 I got the syntax error. Why? My php version: D:\>php -version PHP 5.3.1 (cli) (built: Nov 19 2009 10:17:43) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies I'm currently not on this list, please Cc your comment to me. Thanks in advance. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array conversion
Hi guys. How to convert an array like: Array ( [0] => key1 [1] => value1 [2] => key2 [3] => value2 ) to Array ( [key1] => value1 [key2] => value2 ) Is there a built-in function to do this? Please Cc me. :) Thank you in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to get the 'return type' of a function?
Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a function. For example: === output == Function [ function strstr ] { - Parameters [3] { Parameter #0 [ $haystack ] Parameter #1 [ $needle ] Parameter #2 [ $part ] } } The problem is there's no 'return type' (i.e. 'string' in this example) info about the function. Could you tell me how to retrieve the 'return type'? Thanks. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get the 'return type' of a function?
On Tue, 23 Feb 2010 23:44:17 +0800, Nathan Rixham wrote: As PHP is loosely typed, the only real way around this is to specify a return type in a PHPDoc block, then parse that using reflection to get the @return parameter. another option is to use something like haXe which is an ECMA style typed language that compiles to multiple targets, one of which is PHP. Thanks Nathan for your comment. But I think the PHPDoc stuff is only for user defined functions, right? The Reflection::getDocComment() has no idea about the built-in functions. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SimpleXML: convert xml to text
Hello, I want to convert some xml stuff to simple string using php, say: left center1okcenter2right XML; $xml = simplexml_load_string($string); echo $xml; ?> The code will output "left right" while all the central stuff was lost. How should I print it as "left center1 ok center2 right" ? Thanks in advance, and please Cc me. :) -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SimpleXML: convert xml to text
On Sun, 14 Mar 2010 22:02:22 +0800, Ashley Sheridan wrote: On Sun, 2010-03-14 at 21:58 +0800, Dasn wrote: Hello, I want to convert some xml stuff to simple string using php, say: left center1okcenter2right XML; $xml = simplexml_load_string($string); echo $xml; ?> The code will output "left right" while all the central stuff was lost. How should I print it as "left center1 ok center2 right" ? Thanks in advance, and please Cc me. :) Can't you just call strip_tags() on the string? As you don't need to echo any attribute values, I would have thought it would be perfect. As XML is meant to be well-formed anyway, strip_tags shouldn't cause any problems with broken or missing closing tags. Thanks Ashley for your reply. Sorry that my description was not clear enough. Actually I don't want to just strip the tags, sometimes I also wanna change some elements. For another example: "blastrip_tagsbla". When output, I also want to make some change to the data depending on the tags, say, trying to append a pair of "()" to the "" element, printing it as "bla strip_tags() bla". The problem is when I processing the nodes with SimpleXML, I couldn't get the right order of the data. That is : "echo $xml->a, (string) $xml->a->function . '()'" // prints "bla bla strip_tags()" Thank you anyway. Cc please. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SimpleXML: convert xml to text
On Sun, 14 Mar 2010 22:02:22 +0800, Ashley Sheridan wrote: On Sun, 2010-03-14 at 21:58 +0800, Dasn wrote: Hello, I want to convert some xml stuff to simple string using php, say: left center1okcenter2right XML; $xml = simplexml_load_string($string); echo $xml; ?> The code will output "left right" while all the central stuff was lost. How should I print it as "left center1 ok center2 right" ? Thanks in advance, and please Cc me. :) Well I change to use xmlparser instead, never mind. :) -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php