php-general Digest 28 Aug 2008 07:22:34 -0000 Issue 5649

Topics (messages 278827 through 278857):

Re: Sending a POST variable to an ASP page
        278827 by: Nathan Nobbe
        278834 by: shaun thornburgh
        278835 by: Nathan Nobbe
        278855 by: Nathan Nobbe

Re: concatenating with "." or ","
        278828 by: Robert Cummings
        278837 by: tedd
        278838 by: tedd
        278845 by: tedd
        278847 by: Stut
        278849 by: Jason Pruim

Re: Regex for email validation
        278829 by: Per Jessen
        278836 by: Lupus Michaelis
        278840 by: tedd
        278843 by: tedd
        278844 by: Kevin Waterson
        278848 by: mike
        278857 by: Per Jessen

About the magic function __call
        278830 by: Paulo Sousa
        278831 by: Nathan Nobbe
        278832 by: Nathan Nobbe
        278833 by: Paulo Sousa

Re: Variable name as a string
        278839 by: tedd
        278841 by: Maciek Sokolewicz
        278842 by: Micah Gersten
        278846 by: tedd
        278850 by: Shawn McKenzie
        278851 by: Micah Gersten
        278852 by: Chris
        278853 by: Ross McKay
        278854 by: Ross McKay

! function_exists("curl_init") BUT curl_init exists and works.
        278856 by: daniel danon

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 ---
heres a simple example shaun,

$cH = curl_init('url to asp box');
curl_setopt_array(
$cH,
array(
        CURLOPT_POST => TRUE,
*     CURLOPT_POSTFIELDS* => array(
            'yourParamName' => 'yourParamVal'
        )
 ));
$response = curl_exec($cH);

personally though, i prefer the http extension and its much cleaner api.

-nathan

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



> To: [EMAIL PROTECTED]> Date: Wed, 27 Aug 2008 14:07:31 -0500> From: [EMAIL 
> PROTECTED]> Subject: [PHP] Re: Sending a POST variable to an ASP page> > 
> shaun thornburgh wrote:> > Hi,> > > > I need to send a post variable to an 
> ASP page, can I do this within my PHP script?> > > > I don't need to view the 
> page, or get any acknowledgment back, just send the single POST variable...> 
> > > > Thanks for your advice> > 
> _________________________________________________________________> > Get 
> Hotmail on your mobile from Vodafone > > 
> http://clk.atdmt.com/UKM/go/107571435/direct/01/> > If you don't mind 
> building the headers yourself in the code, it's just a > matter of using 
> fsockopen() and then fputs().> > -Shawn> > -- > PHP General Mailing List 
> (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php> 
 
Hi Shawn, I have tried the following but it doesnt seem to work: 
foreach($_POST['newsletter-group'] as $key => $value){   
$_POST['addressbookid'] = $value;   $out = "POST /signup.ashx";    $fp = 
fsockopen("server-url", 80, $errno, $errstr, 30);   if (!$fp) {    echo 
"$errstr ($errno)<br />\n";   } else {     fputs($fp, $out . "\r\n");    }    
fclose($fp);  } Am I building the headers incorrectly?
_________________________________________________________________
Make a mini you on Windows Live Messenger!
http://clk.atdmt.com/UKM/go/107571437/direct/01/

--- End Message ---
--- Begin Message ---
On Wed, Aug 27, 2008 at 2:41 PM, shaun thornburgh <
[EMAIL PROTECTED]> wrote:

> > To: [EMAIL PROTECTED]> Date: Wed, 27 Aug 2008 14:07:31 -0500>
> From: [EMAIL PROTECTED]> Subject: [PHP] Re: Sending a POST variable to
> an ASP page> > shaun thornburgh wrote:> > Hi,> > > > I need to send a post
> variable to an ASP page, can I do this within my PHP script?> > > > I don't
> need to view the page, or get any acknowledgment back, just send the single
> POST variable...> > > > Thanks for your advice> >
> _________________________________________________________________> > Get
> Hotmail on your mobile from Vodafone > >
> http://clk.atdmt.com/UKM/go/107571435/direct/01/> > If you don't mind
> building the headers yourself in the code, it's just a > matter of using
> fsockopen() and then fputs().> > -Shawn> > -- > PHP General Mailing List (
> http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
>
> Hi Shawn, I have tried the following but it doesnt seem to work:
> foreach($_POST['newsletter-group'] as $key => $value){
> $_POST['addressbookid'] = $value;   $out = "POST /signup.ashx";    $fp =
> fsockopen("server-url", 80, $errno, $errstr, 30);   if (!$fp) {    echo
> "$errstr ($errno)<br />\n";   } else {     fputs($fp, $out . "\r\n");    }
>  fclose($fp);  } Am I building the headers incorrectly?
> _________________________________________________________________
> Make a mini you on Windows Live Messenger!
> http://clk.atdmt.com/UKM/go/107571437/direct/01/



dude, honestly, why would you take that approach unless you had a particular
reason for it?  especially when you can knock it out in 2 minutes w/ curl...

btw, google is pretty key as usual, try googling 'php curl post' ;)

-nathan

--- End Message ---
--- Begin Message ---
say jesse,

if youre subscribed to php-general, you likely did that yourself ;)

>  > PHP General Mailing List (http://www.php.net/)
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  > To contact the list administrators, e-mail: [EMAIL PROTECTED]


let me know what the police have to say about it :p

-nathan

On Wed, Aug 27, 2008 at 10:32 PM, jesse church <[EMAIL PROTECTED]>wrote:

> stop emailing me......
> now..........................................................................................................i
> never signed up for shit leave me alone taking me off you emailing list or i
> will file charges with the police
>
> --- On *Wed, 8/27/08, Nathan Nobbe <[EMAIL PROTECTED]>* wrote:
>
> From: Nathan Nobbe <[EMAIL PROTECTED]>
> Subject: Re: [PHP] Re: Sending a POST variable to an ASP page
> To: "shaun thornburgh" <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Date: Wednesday, August 27, 2008, 3:45 PM
>
>
> On Wed, Aug 27, 2008 at 2:41 PM, shaun thornburgh <[EMAIL PROTECTED]> wrote:
>
> > > To: [EMAIL PROTECTED]> Date: Wed, 27 Aug 2008 14:07:31
> -0500>
> > From: [EMAIL PROTECTED]> Subject: [PHP] Re: Sending a POST variable
> to
> > an ASP page> > shaun thornburgh wrote:> > Hi,> > >
> > I need to send a post
> > variable to an ASP page, can I do this within my PHP script?> > >
> > I don't
> > need to view the page, or get any acknowledgment back, just send the
> single
> > POST variable...> > > > Thanks for your advice> >
> > _________________________________________________________________> >
> Get
> > Hotmail on your mobile from Vodafone > >
> > http://clk.atdmt.com/UKM/go/107571435/direct/01/> > If you don't
> mind
> > building the headers yourself in the code, it's just a > matter of
> using
> > fsockopen() and then fputs().> > -Shawn> > -- > PHP General
> Mailing List (
> > http://www.php.net/)> To unsubscribe, visit:http://www.php.net/unsub.php>
> >
> > Hi Shawn, I have tried the following but it doesnt seem to work:
> > foreach($_POST['newsletter-group'] as $key => $value){
> > $_POST['addressbookid'] = $value;   $out = "POST
> /signup.ashx";    $fp =
> > fsockopen("server-url", 80, $errno, $errstr, 30);   if (!$fp) {
>   echo
> > "$errstr ($errno)<br />\n";   } else {     fputs($fp,
> $out . "\r\n");    }
> >  fclose($fp);  } Am I building the headers incorrectly?
> > _________________________________________________________________
> > Make a mini you on Windows Live Messenger!
> > http://clk.atdmt.com/UKM/go/107571437/direct/01/
>
>
>
> dude, honestly, why would you take that approach unless you had a particular
> reason for it?  especially when you can knock it out in 2 minutes w/ curl...
>
> btw, google is pretty key as usual, try googling 'php curl post' ;)
>
> -nathan
>
>
>

--- End Message ---
--- Begin Message ---
On Wed, 2008-08-27 at 14:57 -0400, tedd wrote:
> At 1:55 PM -0400 8/27/08, Robert Cummings wrote:
> >My memory may be a bit off but I think tedd is around 4017 (he uses
> >rocks if you can recall) but I have no idea about your age... myself I'm
> >a virile 34 year old :D
> >
> >Cheers,
> >Rob.
> 
> I've been around long enough to remember that pyramids were the first 
> real constants.
> 
> As for 34, I thought you were younger. But at 34 ,you've already 
> passed your prime (in all things) -- you might as well be as old as 
> me for it's all downhill from there.

I dunno... I've got another son on his way due early October... and with
the other 2 kids I swear it feels like an uphill climb :) At any rate,
I've got another prime coming up at 37... then there's 41, 43, 47, etc.
Plenty of prime left in me ;)

> My advice, start saving now for your Internet connection in the rest 
> home -- because they won't allow you to bring your blow-up doll and 
> what are you going to do for entertainment without the net?

Saving? I bleed money to things like kindergarten supplies, clothes,
food, gymnastics, swimming, play groups, etc, etc, etc. My wife stays
home though, so at least there's no daycare costs and I see my kids a
lot.

I'm a happy bleeder though :D

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
At 7:35 PM +0100 8/27/08, Stut wrote:
On 27 Aug 2008, at 18:44, Jay Blanchard wrote:
[snip]
Bah, who put me in a box with crayons. I'm a scalpel for crying out
loud. Anyways, I could wax on forever, but cutting to the point... I
think I'm hanging with the wrong bunch of tools.

(multiple puns intended ;)
[/snip]

I, myself, am a hammer....

I like to think of myself as a laparoscopic surgery machine.

-Stut

So, what are you doing programming? :-)

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 2:54 PM -0400 8/27/08, Robert Cummings wrote:
Pamela Anderson still confuses me... as do a lot of so called stars.
They all look so plasticky. I tend to err on the side of caution and
just assume they're not real.

Cheers,
Rob.


Well, I'm not confused I know what all of those plasticky parts are for. I'm a guy, real doesn't count for much. :-)

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 1:03 PM -0500 8/27/08, Jay Blanchard wrote:
[snip]
My memory may be a bit off but I think tedd is around 4017 (he uses
rocks if you can recall)
[/snip]

I am certainly no less virile. Let's see if anyone can GREP this
reference for my age; I was born "The Day the Music Died"

That's easy -- Bye bye American pie. Drove my Chevy to the levy and the levy was dry. Good old boys drinking whiskey and Rye singing this will be the day that I die... this will be the day that I die.

Who can identify (no fair using Google):

"There she was friends and neighbors in all her radiant beauty eating on a raisin, a pomegranate, a bowl of chitlins, two bananas, three Hershey bars, listening to the Grand Old Opry of TV, sipping on a RC coke a cola and signing "Does your crewing gum lose it's favor and the bed post over night."

How about?

"Ou ee, ou ah ah, ting tang wala wala bing bang"?

I can go back a couple of centuries on this game.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 27 Aug 2008, at 22:26, tedd wrote:
At 7:35 PM +0100 8/27/08, Stut wrote:
On 27 Aug 2008, at 18:44, Jay Blanchard wrote:
[snip]
Bah, who put me in a box with crayons. I'm a scalpel for crying out
loud. Anyways, I could wax on forever, but cutting to the point... I
think I'm hanging with the wrong bunch of tools.

(multiple puns intended ;)
[/snip]

I, myself, am a hammer....

I like to think of myself as a laparoscopic surgery machine.

-Stut

So, what are you doing programming? :-)

I like to take the occasional holiday doing something simpler than surgery. PHP fits the bill quite nicely.

-Stut

--
http://stut.net/

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

On Aug 27, 2008, at 6:53 PM, tedd wrote:

At 1:03 PM -0500 8/27/08, Jay Blanchard wrote:
[snip]
My memory may be a bit off but I think tedd is around 4017 (he uses
rocks if you can recall)
[/snip]

I am certainly no less virile. Let's see if anyone can GREP this
reference for my age; I was born "The Day the Music Died"

That's easy -- Bye bye American pie. Drove my Chevy to the levy and the levy was dry. Good old boys drinking whiskey and Rye singing this will be the day that I die... this will be the day that I die.

Who can identify (no fair using Google):

"There she was friends and neighbors in all her radiant beauty eating on a raisin, a pomegranate, a bowl of chitlins, two bananas, three Hershey bars, listening to the Grand Old Opry of TV, sipping on a RC coke a cola and signing "Does your crewing gum lose it's favor and the bed post over night."

That one no...


How about?

"Ou ee, ou ah ah, ting tang wala wala bing bang"?

This one I know :) Only because my wife makes me watch grease though

Lets see if you can get this one:

The punk rolled up his big blue eyes
And said to the jocker, "Sandy,I've hiked and hiked and wandered too,
But I ain't seen any candy.I've hiked and hiked till my feet are sore
And I'll be damned if I hike any moreTo be buggered sore like a hobo's whore"

?



--- End Message ---
--- Begin Message ---
Lupus Michaelis wrote:

> Per Jessen a écrit :
> 
>> That format is about as dead as the dinosaurs.
> 
>    Why ?

I don't know, but I suspect due to lack of support in popular mailers
and mail-servers.  Also, the use of quotes does make it cumbersome to
work with, both as a user and as a mailserver admin. 


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
Per Jessen a écrit :

I don't know, but I suspect due to lack of support in popular mailers
and mail-servers.  Also, the use of quotes does make it cumbersome to
work with, both as a user and as a mailserver admin.

I had to write some pieace of code that can handle "toto toto"@ndd five years ago, it was Lotus Mail habits of the end users ;)

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

--- End Message ---
--- Begin Message ---
At 8:35 PM +0200 8/27/08, Per Jessen wrote:
Go on, send me that email to '[EMAIL PROTECTED]' ... for what it's worth, I
can't even define an account like that, so my mailserver might well
reject it.

Yes, you are right.

I was thinking of something else, namely that the LHS of the email address is case-sensitive -- this was something that was discussed about five years ago on the IDNS list, of which I attended.

Considering that the list was created to solve the IDNS problem, I mistakenly remembered them were discussing IDNS problems, but instead they were discussing case-sensitivity.

Sorry to add to the confusion.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 8:35 PM +0200 8/27/08, Per Jessen wrote:
 > So, regardless of the documentation, which may be outdated, I know
 > that Unicode characters can be used in IDNS and thus on both sides of
 the @,

You're wrong - IDNs only apply to the right side of the @. (check out
what the 'D' means).


The D in IDNS is Internationalized "Domain" Names -- note what the 'I' stands for.

I was wrong to say that Unicode code points can be used on the LHS of the @ but domain names contain Unicode code points (in fact, that's all they contain) and thus these code points can appear on the RHS of email.

For example, one *can* use other than ASCII characters in a domain name -- that's what the IDNS WG was for solving.

The WG did solve this issue and came up with a way to do that -- the current algorithm is called PUNYCODE which allows Unicode code-points to appear in a domain name. I know this to be true because I have several domains that lie outside the standard ASCII AND they are real domains that have real web sites.

For example:

http://xn--u2g.com

If you have a browser (like Safari) that is capable of showing the URL in it's native charset, then you will see the Rx.com in the url. If not, then you'll see xn--u2g.com.

Now, email can be sent from that domain, but I have not found an application that will send nor receive it. The software has simply not caught up with the technology.

One thing for sure, as the rest of the world logs on, more and more people will demand that their applications will implement the capabilities of the current IDNS.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
This one time, at band camp, Yeti <[EMAIL PROTECTED]> wrote:

> <?php
> # this one worked fine for me, but it does not cover the full RFC
> like: "name" [EMAIL PROTECTED] OR name <[EMAIL PROTECTED]>
> $regex = 
> "^[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+)[EMAIL
>  PROTECTED](\.[a-z0-9-]+)*\.([a-z]{2,})$";
> if (eregi($regex, $email)) {
>  // do something
> }
> # Beware that the filter functions only work under PHP5+. If your PHP
> supports them they should be the preferred choice
> ?>

There is no silver bullet regex to validate all RFC compliant email address.
Many have tried, but they all fail at some point. The best you can do is
cater to most _sane_ addresses.

And when the domain name space is opened up, well, you will back to strpos() 
and @

Kevin

--- End Message ---
--- Begin Message ---
Honestly, I'd stick to using php's filter extension.

It -should- be the best one out there. If it is not processing
something it should, then it's a bug - submit it so all of us benefit
:)

I am tired of trying to find regexps and all that every time, I put my
stock into PHP's core when I can.

On 8/27/08, Lupus Michaelis <[EMAIL PROTECTED]> wrote:
> mike a écrit :
> >
> > php should have a good check built-in.
> >
> > see http://www.php.net/manual/en/function.filter-var.php
> >
>
>  Argh ! Howmany times it is in ? I spent so many time to write a regex that
> belongs the RFC822 :-/ Because all the regex in answer here was false. They
> don't allow email like "Mickael Doodoo"@lupusmic.com nor
> [EMAIL PROTECTED] ; and they are valuable email addresses. Without
> the fact that a top level domain isn't always between two and three
> characters (think about .museum).
>
> --
> Mickaël Wolff aka Lupus Michaelis
> http://lupusmic.org
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
tedd wrote:

> The WG did solve this issue and came up with a way to do that -- the
> current algorithm is called PUNYCODE which allows Unicode code-points
> to appear in a domain name. I know this to be true because I have
> several domains that lie outside the standard ASCII AND they are real
> domains that have real web sites.

That was never in dispute, Tedd - IDNs are well known, certainly around
here. 

> If you have a browser (like Safari) that is capable of showing the
> URL in it's native charset, then you will see the Rx.com in the url.
> If not, then you'll see xn--u2g.com.

I think most browsers will work with IDNs today, possibly with the
exception of MSIE (?)

> Now, email can be sent from that domain, but I have not found an
> application that will send nor receive it. The software has simply
> not caught up with the technology.

Which is weird, to say the least.


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
Hi there!

I'm working with the following code:

<?php

abstract class Foo{

protected $a;
protected $b;
protected $c;

 function __construct($arg){
 $this->a = $arg;
 }

 function __call($function, $args){
 $this->b = $function;
 $this->c = $args;
 $this->doWhatever();
 }

 private doWhatever(){
 }
}


class Boo extends Foo{

protected $e;

public function __construct(){
 parent::__construct('Blah');
 }

public function drive(){
  $e = 'testing';
  parent::drive($e);
 }
}


$br = new Boo();
$br->drive();



But I get a Fatal error: Call to undefined method Foo::drive()

The magic fuction __call don't catch the "drive()". Why not?

I need another idea for this problem and avoid edit the abstract class.

Sorry about the english.

Thanks for any help

--- End Message ---
--- Begin Message ---
On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa <[EMAIL PROTECTED]>wrote:

> Hi there!
>
> I'm working with the following code:
>
> <?php
>
> abstract class Foo{
>
> protected $a;
> protected $b;
> protected $c;
>
>  function __construct($arg){
>  $this->a = $arg;
>  }
>
>  function __call($function, $args){
>  $this->b = $function;
>  $this->c = $args;
>  $this->doWhatever();
>  }
>
>  private doWhatever(){
>  }
> }
>
>
> class Boo extends Foo{
>
> protected $e;
>
> public function __construct(){
>  parent::__construct('Blah');
>  }
>
> public function drive(){
>  $e = 'testing';
>  parent::drive($e);
>  }
> }
>
>
> $br = new Boo();
> $br->drive();
>
>
>
> But I get a Fatal error: Call to undefined method Foo::drive()
>
> The magic fuction __call don't catch the "drive()". Why not?
>
> I need another idea for this problem and avoid edit the abstract class.


looks like __call() might not work through a subclass if defined in the
parent; i might poke around in the .phpt tests that come w/ the php source
to ensure this is the correct behavior.

in the meantime you can get away w/ some variant this ugliness,

class B extends A {
    function __call($method, $args) {
        return parent::__call($method, $args);
    }
}

-nathan

--- End Message ---
--- Begin Message ---
On Wed, Aug 27, 2008 at 1:49 PM, Nathan Nobbe <[EMAIL PROTECTED]>wrote:

> On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa <[EMAIL PROTECTED]>wrote:
>  ...
>

this *should* work,

here is a test, tests/classes/__call_005.phpt, you can take the part beneath
the --FILE-- section and see if it blows up on your system or not.
right now, im getting errors on a php5.2.5 system, and its working as
expected on a php5.2.6 system.

--TEST--
When __call() is invoked via ::, ensure private implementation of __call()
in superclass is accessed without error.
--FILE--
<?php
class A {
    private function __call($strMethod, $arrArgs) {
        echo "In " . __METHOD__ . "($strMethod, array(" .
implode(',',$arrArgs) . "))\n";
        var_dump($this);
    }
}

class B extends A {
    function test() {
        A::test1(1,'a');
        B::test2(1,'a');
        self::test3(1,'a');
        parent::test4(1,'a');
    }
}

$b = new B();
$b->test();
?>
--EXPECTF--
In A::__call(test1, array(1,a))
object(B)#1 (0) {
}
In A::__call(test2, array(1,a))
object(B)#1 (0) {
}
In A::__call(test3, array(1,a))
object(B)#1 (0) {
}
In A::__call(test4, array(1,a))
object(B)#1 (0) {
}

also, i found in the code you posted, you are missing a 'function' in front
of doWhatever (cause a parse error, which is why i mention it); w/ the
following modification to your code, its running fine on a php 5.2.6 system,
and choking on 5.2.5;

      function __call($function, $args){
                var_dump($function);
                var_dump($args);
                  $this->doWhatever();
                  }

                   private function doWhatever() {
                    }

[EMAIL PROTECTED] ~/unpack/php-5.2.6RC3/tests/classes $ php testOtherStuff.php
string(5) "drive"
array(1) {
  [0]=>
  string(7) "testing"
}

-nathan

(sorry for the long-winded post)

--- End Message ---
--- Begin Message ---
My information was incomplete: I'm running php 5.1.2 (a requirement from the
customer).
I found this http://bugs.php.net/bug.php?id=42937

I "coded" this without testing, using only the idea. Thanks!

Thanks for the help Nathan!


2008/8/27 Nathan Nobbe <[EMAIL PROTECTED]>

> On Wed, Aug 27, 2008 at 1:49 PM, Nathan Nobbe <[EMAIL PROTECTED]>wrote:
>
>> On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa <[EMAIL PROTECTED]
>> > wrote:
>>  ...
>>
>
> this *should* work,
>
> here is a test, tests/classes/__call_005.phpt, you can take the part
> beneath the --FILE-- section and see if it blows up on your system or not.
> right now, im getting errors on a php5.2.5 system, and its working as
> expected on a php5.2.6 system.
>
> --TEST--
> When __call() is invoked via ::, ensure private implementation of __call()
> in superclass is accessed without error.
> --FILE--
> <?php
> class A {
>     private function __call($strMethod, $arrArgs) {
>         echo "In " . __METHOD__ . "($strMethod, array(" .
> implode(',',$arrArgs) . "))\n";
>         var_dump($this);
>     }
> }
>
> class B extends A {
>     function test() {
>         A::test1(1,'a');
>         B::test2(1,'a');
>         self::test3(1,'a');
>         parent::test4(1,'a');
>     }
> }
>
> $b = new B();
> $b->test();
> ?>
> --EXPECTF--
> In A::__call(test1, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test2, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test3, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test4, array(1,a))
> object(B)#1 (0) {
> }
>
> also, i found in the code you posted, you are missing a 'function' in front
> of doWhatever (cause a parse error, which is why i mention it); w/ the
> following modification to your code, its running fine on a php 5.2.6 system,
> and choking on 5.2.5;
>
>       function __call($function, $args){
>                 var_dump($function);
>                 var_dump($args);
>                   $this->doWhatever();
>                   }
>
>                    private function doWhatever() {
>                     }
>
> [EMAIL PROTECTED] ~/unpack/php-5.2.6RC3/tests/classes $ php testOtherStuff.php
> string(5) "drive"
> array(1) {
>   [0]=>
>   string(7) "testing"
> }
>
> -nathan
>
> (sorry for the long-winded post)
>

--- End Message ---
--- Begin Message ---
At 1:58 PM -0500 8/27/08, Shawn McKenzie wrote:
ioannes wrote:
Actually, you are right, as you just put the checkbox index in the POST and get the value from there. So you just need the number of checkboxes...sorry.

for ($i = 1; $i <= 4; $i++)
   {
   $a = 'a' . $i;
   $b = 'whatever' . $i;
   if($_POST[$a] == 'on')
      {
       my_array[] = $_POST[$b]
      }
   }
"

John


Either I'm missing what you're trying to do, or this has become incredibly over complicated!

-Shawn

It's not over complicated, but just a method of passing checked checkbox values to a php array. Do you have something better?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 1:58 PM -0500 8/27/08, Shawn McKenzie wrote:
ioannes wrote:
Actually, you are right, as you just put the checkbox index in the POST and get the value from there. So you just need the number of checkboxes...sorry.

for ($i = 1; $i <= 4; $i++)
   {
   $a = 'a' . $i;
   $b = 'whatever' . $i;
   if($_POST[$a] == 'on')
      {
       my_array[] = $_POST[$b]
      }
   }
"

John


Either I'm missing what you're trying to do, or this has become incredibly over complicated!

-Shawn

It's not over complicated, but just a method of passing checked checkbox values to a php array. Do you have something better?

Cheers,

tedd


Well, this seems easier/cleaner to me:

<input type="check" name="my_checkboxes[1]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[2]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[3]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[4]" value="1" /> 1<br />

$my_checked_checkboxes = $_REQUEST['my_checkboxes']; // whichever you wish, $_GET or $_POST, I don't care right now; you choose.
--- End Message ---
--- Begin Message ---
First, the type is checkbox, not check.  Second, you cannot put a value
in the brackets  for a checkbox group.  A checkbox group is passed to
PHP automatically as an array.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Maciek Sokolewicz wrote:
> Well, this seems easier/cleaner to me:
>
> <input type="check" name="my_checkboxes[1]" value="1" /> 1<br />
> <input type="check" name="my_checkboxes[2]" value="1" /> 1<br />
> <input type="check" name="my_checkboxes[3]" value="1" /> 1<br />
> <input type="check" name="my_checkboxes[4]" value="1" /> 1<br />
>
> $my_checked_checkboxes = $_REQUEST['my_checkboxes'];    // whichever
> you wish, $_GET or $_POST, I don't care right now; you choose.
>

--- End Message ---
--- Begin Message ---
At 12:07 AM +0200 8/28/08, Maciek Sokolewicz wrote:
tedd wrote:
At 1:58 PM -0500 8/27/08, Shawn McKenzie wrote:
ioannes wrote:
Actually, you are right, as you just put the checkbox index in the POST and get the value from there. So you just need the number of checkboxes...sorry.

for ($i = 1; $i <= 4; $i++)
   {
   $a = 'a' . $i;
   $b = 'whatever' . $i;
   if($_POST[$a] == 'on')
      {
       my_array[] = $_POST[$b]
      }
   }


Either I'm missing what you're trying to do, or this has become incredibly over complicated!

-Shawn

It's not over complicated, but just a method of passing checked checkbox values to a php array. Do you have something better?

Cheers,

tedd


Well, this seems easier/cleaner to me:

<input type="check" name="my_checkboxes[1]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[2]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[3]" value="1" /> 1<br />
<input type="check" name="my_checkboxes[4]" value="1" /> 1<br />

$my_checked_checkboxes = $_REQUEST['my_checkboxes']; // whichever you wish, $_GET or $_POST, I don't care right now; you choose.

Yeah, I remember that -- but a bit different.

Don't use indexes, but rather just my_checkboxes[]

and on the php side

$my_checked_checkboxes = $_REQUEST['my_checkboxes'];

The array $my_checked_checkboxes equals the $_REQUEST$_/$_POST/$_GET array -- all the indexes will match (i.e., $my_checked_checkboxes[3] is the same as $_POST[3]).

The only problem I have with that method is that the [] becomes confusing with dealing with javascript that can also handles the form.

One of the ways to get around this is to:

<input type="checkbox" name="my_checkboxes[]" id="my_checkbox_1" value="1" >

That way php will use "name" and javascript will use "id".

But, there are lot's of ways to do this.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 1:58 PM -0500 8/27/08, Shawn McKenzie wrote:
ioannes wrote:
Actually, you are right, as you just put the checkbox index in the POST and get the value from there. So you just need the number of checkboxes...sorry.

for ($i = 1; $i <= 4; $i++)
   {
   $a = 'a' . $i;
   $b = 'whatever' . $i;
   if($_POST[$a] == 'on')
      {
       my_array[] = $_POST[$b]
      }
   }
"

John


Either I'm missing what you're trying to do, or this has become incredibly over complicated!

-Shawn

It's not over complicated, but just a method of passing checked checkbox values to a php array. Do you have something better?

Cheers,

tedd


I guess you missed my last post, it was maybe the first or second reply to this thread:

<input type="checkbox" name="data[field_name]" id="my_checkbox_1" value="1" >

Then on post you have a $_POST['data'] array that contains the field_names as keys and the checkbox values as values.

That's why I was wondering if I was missing something.

-Shawn

--- End Message ---
--- Begin Message ---
You cannot have anything in the brackets for the name in a checkbox
group.  The brackets specify that it is an array.  The name of the array
is the key in $_POST that contains the values of the checkbox group that
were checked.  You can have as many groups as you like.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Shawn McKenzie wrote:
> I guess you missed my last post, it was maybe the first or second
> reply to this thread:
>
> <input type="checkbox" name="data[field_name]" id="my_checkbox_1"
> value="1" >
>
> Then on post you have a $_POST['data'] array that contains the
> field_names as keys and the checkbox values as values.
>
> That's why I was wondering if I was missing something.
>
> -Shawn
>

--- End Message ---
--- Begin Message ---
Micah Gersten wrote:
You cannot have anything in the brackets for the name in a checkbox
group.  The brackets specify that it is an array.  The name of the array
is the key in $_POST that contains the values of the checkbox group that
were checked.  You can have as many groups as you like.

Eh? Course you can.

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" name="data[field_name][]" id="my_checkbox_1" value="1" > Val 1 <input type="checkbox" name="data[field_name][]" id="my_checkbox_2" value="2" > Val 2

<input type="checkbox" name="data[field2][]" id="field1" value="1" > Val 1 (Field 1) <input type="checkbox" name="data[field2][]" id="field2" value="2" > Val 2 (Field 2)
<input type="submit">
</form>
<pre>
<?php
print_r($_POST);


You end up with a multi-dimensional array.


Array
(
    [data] => Array
        (
            [field_name] => Array
                (
                    [0] => 1
                )

            [field2] => Array
                (
                    [0] => 1
                    [1] => 2
                )

        )

)

--
Postgresql & php tutorials
http://www.designmagick.com/


--- End Message ---
--- Begin Message ---
On Wed, 27 Aug 2008 22:25:44 -0500, Micah Gersten wrote:

>You cannot have anything in the brackets for the name in a checkbox
>group.  [...]

Bollocks.

<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<p>option 1 - colour: <input type="text" name="options[colour]"/></p>
<p>option 2 - flavour: <input type="text" name="options[flavour]"/></p>
<p>option 3 - size: <input type="text" name="options[size]"/></p>
<p><input type="submit"/></p>
</form>

<?php
function test() {
        $colour = $_POST['options']['colour'];
        echo "<p>colour: $colour</p>\n";

        $flavour = $_POST['options']['flavour'];
        echo "<p>flavour: $flavour</p>\n";

        $size = $_POST['options']['size'];
        echo "<p>size: $size</p>\n";
}
?>

NB: no quotes around array key!

I found this very handy for having variable product options on a simple
shopping cart.
--  
Ross McKay, Toronto, NSW Australia
"The lawn could stand another mowing; funny, I don't even care"
- Elvis Costello

--- End Message ---
--- Begin Message ---
More specifically:

<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<p>option 1 - colour:<br/>
# <input type="checkbox" name="options[colour][]" value="red"/> red<br/>
# <input type="checkbox" name="options[colour][]" value="green"/>
green<br/>
# <input type="checkbox" name="options[colour][]" value="blue"/>
blue</p>
<p><input type="submit"/></p>
</form>

<?php
        foreach($_POST['options']['colour'] as $colour)
                echo "<p>colour: $colour</p>\n";
?>
-- 
Ross McKay, Toronto, NSW Australia
"If ye cannae see the bottom, dinnae complain if ye droon"
- The Wee Book of Calvin

--- End Message ---
--- Begin Message ---
! function_exists("curl_init") BUT curl_init exists and works.

After my host blocked the file_get_contents and other functions, I am
using CURL - but when I do function_exists("curl_init") it returns
false but I can still use it.... anyone knows why?

--- End Message ---

Reply via email to