[PHP] SimpleXML var_dump() weirdness
Hi, It seems that var_dump() of a SimpleXMLElement does not show an attribute of elements that contain text content? I hope my examples might show what I mean: $xml = ''; $simple = new SimpleXMLElement($xml); var_dump($simple); echo $simple->asXML(); This results in: object(SimpleXMLElement)#1 (2) { ["@attributes"]=> array(1) { ["rootattr"]=> string(10) "root value" } ["inner"]=> object(SimpleXMLElement)#2 (1) { ["@attributes"]=> array(1) { ["attr"]=> string(5) "value" } } } ...and that's fine, though it would have been nice to also know that the root element is called "root". The second example manifests the weirdness: $xml = 'attr="value">text'; $simple = new SimpleXMLElement($xml); var_dump($simple); echo $simple->asXML(); Outputs: object(SimpleXMLElement)#1 (2) { ["@attributes"]=> array(1) { ["rootattr"]=> string(10) "root value" } ["inner"]=> string(4) "text" } text Notice that the attribute "attr" of the element "inner" is not displayed. In the third case, I replace the content of the "inner" element with another element: $xml = 'attr="value">'; $simple = new SimpleXMLElement($xml); var_dump($simple); echo $simple->asXML(); Outputs: object(SimpleXMLElement)#1 (2) { ["@attributes"]=> array(1) { ["rootattr"]=> string(10) "root value" } ["inner"]=> object(SimpleXMLElement)#2 (2) { ["@attributes"]=> array(1) { ["attr"]=> string(5) "value" } ["deep"]=> object(SimpleXMLElement)#3 (0) { } } } The "invisible" attributes are still accessible with xpath(), etc (the asXML() dump shows that it is still present, but just not visible. This might be a bug? Or am I just not understanding something? Cheers, Mattias PHP 5.2.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Signing (hand-written signature) pdf document
Hi... I'm thinking about a document management system that can put user signature on the created digital document. Here's the app-flow I can imagine ... My php application creates a pdf document. The pdf document is displayed to user. Using the digital pen, the user will put his/her signature on this document. or Using the touch screen, the user will put his/her signature. The pdf document with the user signature is saved to the db. Has anyone done this before ?? Thanks -- View this message in context: http://www.nabble.com/Signing-%28hand-written-signature%29-pdf-document-tp25884660p25884660.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
uhm, right, I should have better explain that option ... still, if timelimit is 0, I guess connection timeout matters, maybe I am wrong. Thanks. Regards > Date: Tue, 13 Oct 2009 11:31:00 -0700 > Subject: Re: [PHP] How to bypass (pipe) curl_exec return value directly to a > file? > From: larstor...@gmail.com > To: an_...@hotmail.com > CC: magda.hasib...@yahoo.co.uk; php-general@lists.php.net > > 2009/10/13 Andrea Giammarchi : > > > >> > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); > >> > >> I wouldn't recommend setting this to 0 unless you're very sure that > >> the connection will succeed; otherwise, your script will hang > >> indefinitely waiting for the connection to be made. > > > > agreed, it's just he set timeout to zero so I guess he meant the curl > > connection as well otherwise it does not make sense to set the timeout to 0 > > if curl has 10 seconds timeout :-) > > > > Regards > > If he wants to download a very large file then it would make sense to > set_time_limit(0) but leave the curl connect timeout enabled; he > wouldn't want the PHP script timing out partway through a large > download. :) The curl timeout isn't for the transfer; just for making > the connection. > > > Regards, > > Torben _ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010
Re: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
2009/10/13 Andrea Giammarchi : > >> > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); >> >> I wouldn't recommend setting this to 0 unless you're very sure that >> the connection will succeed; otherwise, your script will hang >> indefinitely waiting for the connection to be made. > > agreed, it's just he set timeout to zero so I guess he meant the curl > connection as well otherwise it does not make sense to set the timeout to 0 > if curl has 10 seconds timeout :-) > > Regards If he wants to download a very large file then it would make sense to set_time_limit(0) but leave the curl connect timeout enabled; he wouldn't want the PHP script timing out partway through a large download. :) The curl timeout isn't for the transfer; just for making the connection. Regards, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
> > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); > > I wouldn't recommend setting this to 0 unless you're very sure that > the connection will succeed; otherwise, your script will hang > indefinitely waiting for the connection to be made. agreed, it's just he set timeout to zero so I guess he meant the curl connection as well otherwise it does not make sense to set the timeout to 0 if curl has 10 seconds timeout :-) Regards _ Windows Live Hotmail: Your friends can get your Facebook updates, right from Hotmail®. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009
Re: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
2009/10/13 Andrea Giammarchi : > >> $ch = curl_init($url); >> $fp = fopen('/tmp/curl.out', 'w'); >> curl_setopt($ch, CURLOPT_FILE, $fp); >> curl_exec($ch); >> >> Error checking etc. is of course left up to you. :) > > oops, I sent directly the file name. Let me reformulate the code then: > > > set_time_limit(0); > $fp = fopen('stream.bin', 'wb'); > $ch = curl_init($siteURL); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); > curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); If you're re-using a curl handle then it may be a good idea to set these explicitly. However, these are also the default values so it's not really necessary to set them for a new handle. You're right that it's a good idea to include the 'b' in the fopen() mode. > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); I wouldn't recommend setting this to 0 unless you're very sure that the connection will succeed; otherwise, your script will hang indefinitely waiting for the connection to be made. Regards, Torben > curl_setopt($ch, CURLOPT_FILE, $fp); > curl_exec($ch); > fclose($fp); > > Apologize I did not test it before. > > Regards > > > > Windows Live: Friends get your Flickr, Yelp, and Digg updates when they > e-mail you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Insult my code!
2009/10/13 Eric Bauman : > *sigh* sometimes I really wish PHP allowed one to be a bit more heavy-handed > with types (optional real type hinting would be nice). There's a scalar type-hinting patch floating around somewhere, but then your code would only work on machines with that patch. > I guess I only ever worried about string (from DB) and int (internal call) > as in my specific use I would never be passing a float. > You make an excellent point however; I suppose in the interests of > completeness, forward compatibility etc. I should take into account more > possibilities. Perhaps I should just throw an exception in deposit() etc. if > the argument isn't int and worry about converting elsewhere. I can see two choices - either throw an exception in checkInt() if it's passed anything except an int or a string (which is fine - because you've made the assumption explicit) or change the checkInt() so it deals with ints-masquerading-as-floats. Try: function checkInt($x) { return((string)((int)$x) == $x); } > Also thanks for the sample TestCase code! I've never really thought about > unit testing in PHP, despite doing so in Java etc. Reading about PHPUnit > brought me on to phpUnderControl - interesting stuff! Yup. Pretty graphs. That's not the best unit test example to work from, BTW - the manual will give you better advice than I. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
> $ch = curl_init($url); > $fp = fopen('/tmp/curl.out', 'w'); > curl_setopt($ch, CURLOPT_FILE, $fp); > curl_exec($ch); > > Error checking etc. is of course left up to you. :) oops, I sent directly the file name. Let me reformulate the code then: set_time_limit(0); $fp = fopen('stream.bin', 'wb'); $ch = curl_init($siteURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); fclose($fp); Apologize I did not test it before. Regards _ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010
RE: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
I guess this should work set_time_limit(0); $ch = curl_init($siteURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_FILE, 'stream.bin'); curl_exec($ch); Regards > From: magda.hasib...@yahoo.co.uk > To: php-general@lists.php.net > Date: Tue, 13 Oct 2009 11:01:04 +0700 > Subject: [PHP] How to bypass (pipe) curl_exec return value directly to a file? > > Newbie question. > I need to download a very large amount of xml data from a site using CURL. > > How to bypass (pipe) curl_exec return value directly to a file, without > using memory allocation? > > set_time_limit(0); > $ch = curl_init($siteURL); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); > $mixed = curl_exec($ch); > > How to set/pipe $mixed as a (disk) file, so that data returned by curl_exec > is directly saved to the disk-file, and not involving memory allocation? > > Thank you. > > -PHP 5 > -Windows XP > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > _ Windows Live: Make it easier for your friends to see what you’re up to on Facebook. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
[PHP] Bug in php-cgi.exe
Hello, i thing i found a bug in PHP-cgi.exe I use Php-cgi as fastCgi php-cgi.exe -b host:port i set in environement variables this : PHP_FCGI_CHILDREN=8 PHP_FCGI_MAX_REQUESTS=1000 in the task manager i see only one Php-cgi.exe process (when normaly i must see 9 process no?) and after i send more than 1000 request the php-cgi.exe process died ! and i must manually restart it! Thanks you by advance for you help -- stephane Http://www.arkadia.com/fra/ Http://www.arkadia.com/usa/ Http://www.arkadia.com/rus/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to bypass (pipe) curl_exec return value directly to a file?
2009/10/12 m.hasibuan : > Newbie question. > I need to download a very large amount of xml data from a site using CURL. > > How to bypass (pipe) curl_exec return value directly to a file, without > using memory allocation? > > set_time_limit(0); > $ch = curl_init($siteURL); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); > $mixed = curl_exec($ch); > > How to set/pipe $mixed as a (disk) file, so that data returned by curl_exec > is directly saved to the disk-file, and not involving memory allocation? > > Thank you. Use the CURLOPT_FILE option to set the output to write to the file handle given by the option's value (which must be a writable file handle). For instance: $ch = curl_init($url); $fp = fopen('/tmp/curl.out', 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); Error checking etc. is of course left up to you. :) Good luck, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php