On Mon, Nov 7, 2011 at 5:54 AM, Richard Quadling <[email protected]> wrote:
> On 4 November 2011 16:52, QI.VOLMAR QI <[email protected]> wrote:
>
>> i have this part of code that works with DOMDocument:
>>
>> public function translateNFeXML(NFE $nfe_factory) {
>> $inf_adic = $nfe_factory->createElement('infAdic');
>> if ($this->inf_ad_fisco) {
>> $inf_adic_fisco =
>> $nfe_factory->createElement('infAdicFisco', $this->inf_ad_fisco);
>> $inf_adic->appendChild($inf_adic_fisco);
>> }
>>
>> $string = "a=10&b[]=20&c=30n°&d=40+:50";
>> die(preg_filter('/[^:][[:punct:]]/', '', $string));
>> $inf_cpl = $nfe_factory->createElement('infCpl',
>> $this->inf_complementar);
>>
>> QUESTION: Why the preg_filter causes a end of the application, with no
>> error throwing (even in die don't appears nothing)?
>
>
> preg_filter() returns NULL if there are no matches and the subject is a
> string.
>
> And ...
>
> php -r "die(null);"
>
> outputs nothing.
Here:
>> die(preg_filter('/[^:][[:punct:]]/', '', $string));
Did you really want to do this:
preg_filter('/[^:][[:punct:]]/', '', $string) or die("nothing returned\n");
???
See http://php.net/manual/en/function.preg-filter.php "Return values"
as Richard points out preg_filter returns NULL if there are no matched
in a string.
Now this is interesting:
>> $string = "a=10&b[]=20&c=30n°&d=40+:50";
There is a wide character in that string following 30n. The preg
functions sometimes don't deal well with wide characters in my
experience (it's not 100% anyway), you probably need to use the mb_
functions instead.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php