php-general Digest 24 Sep 2011 10:36:00 -0000 Issue 7492

Topics (messages 315003 through 315020):

Re: Any free online tests to test my PHP knowledge?
        315003 by: Richard Quadling

filter_input and $_POST deep array
        315004 by: jean-baptiste verrey
        315006 by: Al
        315007 by: jean-baptiste verrey
        315008 by: jean-baptiste verrey
        315012 by: Thijs Lensselink
        315013 by: jean-baptiste verrey
        315019 by: Thijs Lensselink

Re: 'Mobile' PHP
        315005 by: Bastien
        315009 by: Lester Caine
        315010 by: Ashley Sheridan
        315011 by: Daniel Brown
        315014 by: Lester Caine
        315016 by: Tommy Pham
        315017 by: Lester Caine
        315018 by: Tommy Pham

Re: Search for string followed by whitespace
        315015 by: Daniel Brown

PHP redirect
        315020 by: muad shibani

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On 22 September 2011 18:53, Mike Hansen <[email protected]> wrote:
> Does anyone know of a site that has an online test of PHP skills? I'd like
> to review my PHP knowledge.
>
> I've already run across this site:
> http://vladalexa.com/scripts/php/test/test_php_skill.html
>
> Thanks,
>
> Mike

I took the ZCE exam and I used "The Zend PHP Certification Practice
Test Book" and the "Zend PHP Certification Study Guide". Both of these
are for PHP4 (though I never actually used PHP4) - so no good now -
unless you use PHP4 of course.

There is a PHP 5 Study Guide
(http://www.phparch.com/books/phparchitects-zend-php-5-certification-study-guide-2nd-edition/)

I have the first edition, so a little out of date now but I do get a
free PDF of the 2nd edition.

Richard.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---
--- Begin Message ---
Hi,

I have using a form that gives me something like
 $_POST=array(
    'login'=>array(
        'email'=>'[email protected]',
        'password'=>'123456'
    )
)

is there a way to use filter_input function to filter the values? I tried
filter_input(INPUT_POST,'login[email]') but it does not work!

Regards,

Jean-Baptiste Verrey

--- End Message ---
--- Begin Message ---


On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
Hi,

I have using a form that gives me something like
  $_POST=array(
     'login'=>array(
         'email'=>'[email protected]',
         'password'=>'123456'
     )
)

is there a way to use filter_input function to filter the values? I tried
filter_input(INPUT_POST,'login[email]') but it does not work!

Regards,

Jean-Baptiste Verrey



foreach() in the manual

--- End Message ---
--- Begin Message ---
What do you mean? I don't see how I could use foreach there

On 23 September 2011 13:31, Al <[email protected]> wrote:

>
>
> On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
>
>> Hi,
>>
>> I have using a form that gives me something like
>>  $_POST=array(
>>     'login'=>array(
>>         'email'=>'[email protected]',
>>         'password'=>'123456'
>>     )
>> )
>>
>> is there a way to use filter_input function to filter the values? I tried
>> filter_input(INPUT_POST,'**login[email]') but it does not work!
>>
>> Regards,
>>
>> Jean-Baptiste Verrey
>>
>>
>
> foreach() in the manual
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
seems that the only solution is to still use $_POST and use filter_var
instead, it could have been better!

On 23 September 2011 14:11, jean-baptiste verrey <
[email protected]> wrote:

> What do you mean? I don't see how I could use foreach there
>
> On 23 September 2011 13:31, Al <[email protected]> wrote:
>
>>
>>
>> On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
>>
>>> Hi,
>>>
>>> I have using a form that gives me something like
>>>  $_POST=array(
>>>     'login'=>array(
>>>         'email'=>'[email protected]',
>>>         'password'=>'123456'
>>>     )
>>> )
>>>
>>> is there a way to use filter_input function to filter the values? I tried
>>> filter_input(INPUT_POST,'**login[email]') but it does not work!
>>>
>>> Regards,
>>>
>>> Jean-Baptiste Verrey
>>>
>>>
>>
>> foreach() in the manual
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

--- End Message ---
--- Begin Message ---
On 09/23/2011 03:17 PM, jean-baptiste verrey wrote:
> seems that the only solution is to still use $_POST and use filter_var
> instead, it could have been better!
You can foreach the $_Post['login'] array and use filter_input on each
iteration to do the filtering.
Or maybe the filter_input_array is a better place to look at. The manual
is your friend.

http://php.net/manual/en/function.filter-input.php

Besides that. Calling filter_var two times won't kill you!
> On 23 September 2011 14:11, jean-baptiste verrey <
> [email protected]> wrote:
>
>> What do you mean? I don't see how I could use foreach there
>>
>> On 23 September 2011 13:31, Al <[email protected]> wrote:
>>
>>>
>>> On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
>>>
>>>> Hi,
>>>>
>>>> I have using a form that gives me something like
>>>>  $_POST=array(
>>>>     'login'=>array(
>>>>         'email'=>'[email protected]',
>>>>         'password'=>'123456'
>>>>     )
>>>> )
>>>>
>>>> is there a way to use filter_input function to filter the values? I tried
>>>> filter_input(INPUT_POST,'**login[email]') but it does not work!
>>>>
>>>> Regards,
>>>>
>>>> Jean-Baptiste Verrey
>>>>
>>>>
>>> foreach() in the manual
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>


--- End Message ---
--- Begin Message ---
foreach cannot work in this situation has filter_input does not work
recursively and work only on the first level of $_POST (or $_GET)
so the best solution seems to be to use filter_var($_POST['var']['var2']);

Thanks anyway

On 23 September 2011 17:13, Thijs Lensselink <[email protected]> wrote:

> On 09/23/2011 03:17 PM, jean-baptiste verrey wrote:
> > seems that the only solution is to still use $_POST and use filter_var
> > instead, it could have been better!
> You can foreach the $_Post['login'] array and use filter_input on each
> iteration to do the filtering.
> Or maybe the filter_input_array is a better place to look at. The manual
> is your friend.
>
> http://php.net/manual/en/function.filter-input.php
>
> Besides that. Calling filter_var two times won't kill you!
> > On 23 September 2011 14:11, jean-baptiste verrey <
> > [email protected]> wrote:
> >
> >> What do you mean? I don't see how I could use foreach there
> >>
> >> On 23 September 2011 13:31, Al <[email protected]> wrote:
> >>
> >>>
> >>> On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> I have using a form that gives me something like
> >>>>  $_POST=array(
> >>>>     'login'=>array(
> >>>>         'email'=>'[email protected]',
> >>>>         'password'=>'123456'
> >>>>     )
> >>>> )
> >>>>
> >>>> is there a way to use filter_input function to filter the values? I
> tried
> >>>> filter_input(INPUT_POST,'**login[email]') but it does not work!
> >>>>
> >>>> Regards,
> >>>>
> >>>> Jean-Baptiste Verrey
> >>>>
> >>>>
> >>> foreach() in the manual
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On 09/23/2011 06:16 PM, jean-baptiste verrey wrote:
> foreach cannot work in this situation has filter_input does not work
> recursively and work only on the first level of $_POST (or $_GET) 
> so the best solution seems to be to use filter_var($_POST['var']['var2']);
I was sure filter_input would work on nested levels. But it doesn't as
you point out.

You could do something like this if you want to filter the same types

array_walk_recursive($_POST, function(&$value) {
    $value = filter_var($value, FILTER_SANITIZE_STRING);
});

>
> Thanks anyway
>
> On 23 September 2011 17:13, Thijs Lensselink <[email protected]
> <mailto:[email protected]>> wrote:
>
>     On 09/23/2011 03:17 PM, jean-baptiste verrey wrote:
>     > seems that the only solution is to still use $_POST and use
>     filter_var
>     > instead, it could have been better!
>     You can foreach the $_Post['login'] array and use filter_input on each
>     iteration to do the filtering.
>     Or maybe the filter_input_array is a better place to look at. The
>     manual
>     is your friend.
>
>     http://php.net/manual/en/function.filter-input.php
>
>     Besides that. Calling filter_var two times won't kill you!
>     > On 23 September 2011 14:11, jean-baptiste verrey <
>     > [email protected]
>     <mailto:[email protected]>> wrote:
>     >
>     >> What do you mean? I don't see how I could use foreach there
>     >>
>     >> On 23 September 2011 13:31, Al <[email protected]
>     <mailto:[email protected]>> wrote:
>     >>
>     >>>
>     >>> On 9/23/2011 5:51 AM, jean-baptiste verrey wrote:
>     >>>
>     >>>> Hi,
>     >>>>
>     >>>> I have using a form that gives me something like
>     >>>>  $_POST=array(
>     >>>>     'login'=>array(
>     >>>>         'email'=>'[email protected] <mailto:[email protected]>',
>     >>>>         'password'=>'123456'
>     >>>>     )
>     >>>> )
>     >>>>
>     >>>> is there a way to use filter_input function to filter the
>     values? I tried
>     >>>> filter_input(INPUT_POST,'**login[email]') but it does not work!
>     >>>>
>     >>>> Regards,
>     >>>>
>     >>>> Jean-Baptiste Verrey
>     >>>>
>     >>>>
>     >>> foreach() in the manual
>     >>>
>     >>> --
>     >>> PHP General Mailing List (http://www.php.net/)
>     >>> To unsubscribe, visit: http://www.php.net/unsub.php
>     >>>
>     >>>
>
>
>     --
>     PHP General Mailing List (http://www.php.net/)
>     To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---

On 2011-09-23, at 4:27 AM, Lester Caine <[email protected]> wrote:

> OK, I can see 'PHP for Android' which seems to have stalled, and I've been 
> playing with other options, but I'm not currently happy with any of this 
> 'mobile' stuff.
> 
> The 'problem' is quite simple ... While mobile broadband might work in some 
> quite limited areas of the UK - like in bigger towns - it's reliability even 
> in smaller towns is simply getting worse! So a number of my customers have 
> been asking me to provide a backup system which is working fine on laptops, 
> but these are a little cumbersome when the guys have to work away from the 
> vehicles. Tablets via broadband work ... while one can get a signal ... and 
> in many areas around here even getting a PHONE signal depends on where you 
> stand ... so I need a working local PHP setup which can take over and 
> provided things like access codes and the like while out of range, and update 
> the main database when back in range.
> 
> Android, mobile windows and the like currently seem very restrictive when it 
> comes to this type of development, so has anybody got any ideas on how to 
> proceed? I though that Android was essentially a strangled version of Linux, 
> so it should be able to run any Linux application?
> 
> -- 
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Depending in what has to be done, could you use HTML5 with local storage and 
sync back up later? 

AFAIK android runs java programs using a custom JVM.  So any app on those 
devices will need to run in java. Not sure that you couldn't port the php 
engine to that, and it would be an interesting task.

Bastien Koert
905-904-0334

--- End Message ---
--- Begin Message ---
Bastien wrote:
Depending in what has to be done, could you use HTML5 with local storage and 
sync back up later?
The whole database is small enough to fit in 100Mb but needs Firebird to access it via PHP.

AFAIK android runs java programs using a custom JVM.  So any app on those 
devices will need to run in java. Not sure that you couldn't port the php 
engine to that, and it would be an interesting task.
That is the bit I'm wanting to do I think, I have no plans to rewrite 5 years worth of PHP into Java ;) It all runs quite happily on a laptop and syncs back when internet is available again, so I may simply have to put a decent Linux distribution on the tablet ... and then there isn't a problem ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---

Lester Caine <[email protected]> wrote:

>Bastien wrote:
>> Depending in what has to be done, could you use HTML5 with local
>storage and sync back up later?
>The whole database is small enough to fit in 100Mb but needs Firebird
>to access
>it via PHP.
>
>> AFAIK android runs java programs using a custom JVM.  So any app on
>those devices will need to run in java. Not sure that you couldn't port
>the php engine to that, and it would be an interesting task.
>That is the bit I'm wanting to do I think, I have no plans to rewrite 5
>years
>worth of PHP into Java ;)
>It all runs quite happily on a laptop and syncs back when internet is
>available
>again, so I may simply have to put a decent Linux distribution on the
>tablet ...
>and then there isn't a problem ...
>
>--
>Lester Caine - G8HFL
>-----------------------------
>Contact - http://lsces.co.uk/wiki/?page=contact
>L.S.Caine Electronic Services - http://lsces.co.uk
>EnquirySolve - http://enquirysolve.com/
>Model Engineers Digital Workshop - http://medw.co.uk//
>Firebird - http://www.firebirdsql.org/index.php
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

As the op noted, there is php for android, which I run on my phone. It doesn't 
have the full capabilities but the base stuff seems to be there. It runs quite 
well in fact.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--- End Message ---
--- Begin Message ---
On Fri, Sep 23, 2011 at 10:19, Ashley Sheridan <[email protected]> 
wrote:
>
> As the op noted, there is php for android, which I run on my phone. It 
> doesn't have the full capabilities but the base stuff seems to be there. It 
> runs quite well in fact.

    I've been running it for about a year now (shortly after the
initial release), and - though it requires an abstraction layer known
as SL4A (Scripting Language for Android) - it works quite well for an
immature project.  Plus, the project maintainers have created a basic
framework that interfaces with the phone's own capabilities, such as
vibrations, LED control, et cetera.  It's fun to play around with once
in a while, but I've yet to dive into it enough to do anything more
than novelty scripts for personal usage.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
>  As the op noted, there is php for android, which I run on my phone. It 
doesn't have the full capabilities but the base stuff seems to be there. It runs 
quite well in fact.
     I've been running it for about a year now (shortly after the
initial release), and - though it requires an abstraction layer known
as SL4A (Scripting Language for Android) - it works quite well for an
immature project.  Plus, the project maintainers have created a basic
framework that interfaces with the phone's own capabilities, such as
vibrations, LED control, et cetera.  It's fun to play around with once
in a while, but I've yet to dive into it enough to do anything more
than novelty scripts for personal usage.

I think that is the major part of the 'problem'. I just want to run the SAME code that runs on the laptops on the tablets ... I don't need any of the parts that are specific to a mobile phone :(

The PHP for Android needs a lot more extensions added to do that.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
Have you looked at Quercus to see if it could run on Android?  If it could,
you can then run your PHP code then.

--- End Message ---
--- Begin Message ---
Tommy Pham wrote:
Have you looked at Quercus to see if it could run on Android?  If it could, you
can then run your PHP code then.
http://techblog.aasisvinayak.com/deploy-php-applications-in-google-app-engine/ popped up while I was searching. The bit I'm still wasting time on at the moment is how to deploy it as a stand alone application on the tablet I have, but I'm not sure that I can pull stuff yet as the 'android marketplace' sites complain that my 'phone is not recognised' :)

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
On Fri, Sep 23, 2011 at 11:37 AM, Lester Caine <[email protected]> wrote:

> Tommy Pham wrote:
>
>> Have you looked at Quercus to see if it could run on Android?  If it
>> could, you
>> can then run your PHP code then.
>>
> http://techblog.aasisvinayak.**com/deploy-php-applications-**
> in-google-app-engine/<http://techblog.aasisvinayak.com/deploy-php-applications-in-google-app-engine/>popped
>  up while I was searching. The bit I'm still wasting time on at the
> moment is how to deploy it as a stand alone application on the tablet I
> have, but I'm not sure that I can pull stuff yet as the 'android
> marketplace' sites complain that my 'phone is not recognised' :)
>
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - 
> http://lsces.co.uk/wiki/?page=**contact<http://lsces.co.uk/wiki/?page=contact>
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>

>From the link you gave, looks like it uses Quercus after all.  So you might
want to see if you could just Quercus running 1st.

--- End Message ---
--- Begin Message ---
On Fri, Sep 23, 2011 at 13:21, Tim Streater <[email protected]> wrote:
>
> Dan,
>
> Thanks for the suggestion but I need to know where the string occurs as I 
> want to then do some excision/incision.

    Consider preg_replace() with that same pattern.  Or, at the most
involved, preg_replace_callback().

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
when I try to go to a URL by using PHP header function so if the URL
contains & it converts it to &amp; so the needed page will not
display correctly I tried to use:

 $url = urldecode($data['feed_link']);

 header ( "Location: $url" );

but I can't get it

--- End Message ---

Reply via email to