On 06/14/2013 02:16 PM, Peter Cowburn wrote:
Hi Adam,
On 14 June 2013 10:29, Adam Kazimierczak <kazym...@gmail.com
<mailto:kazym...@gmail.com>> wrote:
Try running this code:
var_dump(curl_escape(0, 'test'), curl_unescape(0, 'test'));
Both results are NULL and throws E_WARNINGs:
Warning: curl_escape() expects parameter 1 to be resource, integer
given
This falls under the "garbage in, garbage out" rule that we
historically don't document. When given incorrect arguments, most PHP
functions will return NULL and raise a warning. See the note about
this on http://php.net/functions.internal
That explains everything. At first I thought that NULL can be the result
of incorrect arguments, but I was not sure. I tested this with
fseek(0,0) which returned false and that was a thing that had mislead me.
Thank you very much for that information, now everything is clear for me.
NULL as return on failure is also documented in libcurl docs:
http://curl.haxx.se/libcurl/c/curl_escape.html
If you check php-src, you'll see the functions return FALSE when
cURL's curl_easy_(un)escape() returns null.
Yes, I found it. Next time when I will be unsure, I will check php-src.
As I said, they're minor issues and you look to be getting the hang of
how things work. I would support giving you commit karma, to be able
to push these changes to the docs yourself.
Thank you very much.
Cheers,
Adam