Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Mihai Anghel
Check this http://www.php.net/manual/en/ini.core.php#ini.post-max-size


On Mon, Aug 19, 2013 at 9:55 AM, aesbovis aesbo...@gmail.com wrote:

 Hello there
 I am making a little web-based-tool for our studio to progress a large
 amount of data, more than 2000 items, but it seems there is a length limit
 of 1000 to $_POST.

 How can I submit all of the items in one time?

 Thank you!
 aesbovis

 --
 *Anywhere @aesbovis!*



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Szopen Xiao
you can use JSON post

2013/8/19 aesbovis aesbo...@gmail.com:
 Hello there
 I am making a little web-based-tool for our studio to progress a large
 amount of data, more than 2000 items, but it seems there is a length limit
 of 1000 to $_POST.

 How can I submit all of the items in one time?

 Thank you!
 aesbovis

 --
 *Anywhere @aesbovis!*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Jan Ehrhardt
Mihai Anghel in php.general (Mon, 19 Aug 2013 11:30:01 +0300):
Check this http://www.php.net/manual/en/ini.core.php#ini.post-max-size

Keyword: max_input_vars.

Jan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread aesbovis
T
hank you, it works now.


On Mon, Aug 19, 2013 at 5:09 PM, Jan Ehrhardt php...@ehrhardt.nl wrote:

 Mihai Anghel in php.general (Mon, 19 Aug 2013 11:30:01 +0300):
 Check this http://www.php.net/manual/en/ini.core.php#ini.post-max-size

 Keyword: max_input_vars.

 Jan

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
*Anywhere @aesbovis!*


Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread aesbovis
I know Javascript can solve it, but I don't want to use Js.
Thank you all the same.


On Mon, Aug 19, 2013 at 4:32 PM, Szopen Xiao chopins.x...@gmail.com wrote:

 you can use JSON post

 2013/8/19 aesbovis aesbo...@gmail.com:
  Hello there
  I am making a little web-based-tool for our studio to progress a large
  amount of data, more than 2000 items, but it seems there is a length
 limit
  of 1000 to $_POST.
 
  How can I submit all of the items in one time?
 
  Thank you!
  aesbovis
 
  --
  *Anywhere @aesbovis!*




-- 
*Anywhere @aesbovis!*


Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Stuart Dallas
On 19 Aug 2013, at 10:49, aesbovis aesbo...@gmail.com wrote:

 I know Javascript can solve it, but I don't want to use Js.
 Thank you all the same.

I know you've had the right answer, but I think it's worth pointing out that 
use of JSON in no way requires Javascript, despite its name.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

 On Mon, Aug 19, 2013 at 4:32 PM, Szopen Xiao chopins.x...@gmail.com wrote:
 
 you can use JSON post
 
 2013/8/19 aesbovis aesbo...@gmail.com:
 Hello there
 I am making a little web-based-tool for our studio to progress a large
 amount of data, more than 2000 items, but it seems there is a length
 limit
 of 1000 to $_POST.
 
 How can I submit all of the items in one time?
 
 Thank you!
 aesbovis
 
 --
 *Anywhere @aesbovis!*
 
 
 
 
 -- 
 *Anywhere @aesbovis!*


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Matijn Woudt
On Mon, Aug 19, 2013 at 11:54 AM, Stuart Dallas stu...@3ft9.com wrote:

 On 19 Aug 2013, at 10:49, aesbovis aesbo...@gmail.com wrote:

  I know Javascript can solve it, but I don't want to use Js.
  Thank you all the same.

 I know you've had the right answer, but I think it's worth pointing out
 that use of JSON in no way requires Javascript, despite its name.

 -Stuart


You might want to explain how you convert form data to JSON without
javascript?


Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Stuart Dallas
On 19 Aug 2013, at 15:56, Matijn Woudt tijn...@gmail.com wrote:

 
 On Mon, Aug 19, 2013 at 11:54 AM, Stuart Dallas stu...@3ft9.com wrote:
 On 19 Aug 2013, at 10:49, aesbovis aesbo...@gmail.com wrote:
 
  I know Javascript can solve it, but I don't want to use Js.
  Thank you all the same.
 
 I know you've had the right answer, but I think it's worth pointing out that 
 use of JSON in no way requires Javascript, despite its name.
 
 -Stuart
 
 
 You might want to explain how you convert form data to JSON without 
 javascript?

PHP can do it. Ruby can do it. .NET can do it. Just because you want to use 
JSON in a web browser where Javascript is the go-to method, doesn't mean JSON 
requires Javascript.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Matijn Woudt
On Mon, Aug 19, 2013 at 5:20 PM, Stuart Dallas stu...@3ft9.com wrote:

 On 19 Aug 2013, at 15:56, Matijn Woudt tijn...@gmail.com wrote:


 On Mon, Aug 19, 2013 at 11:54 AM, Stuart Dallas stu...@3ft9.com wrote:

 On 19 Aug 2013, at 10:49, aesbovis aesbo...@gmail.com wrote:

  I know Javascript can solve it, but I don't want to use Js.
  Thank you all the same.

 I know you've had the right answer, but I think it's worth pointing out
 that use of JSON in no way requires Javascript, despite its name.

 -Stuart


 You might want to explain how you convert form data to JSON without
 javascript?


 PHP can do it. Ruby can do it. .NET can do it. Just because you want to
 use JSON in a web browser where Javascript is the go-to method, doesn't
 mean JSON requires Javascript.

 -Stuart



Yes, of course they can do it, but then you first need to submit the POST
data (which he could not do because of the above). Javascript is more or
less the only way to do it (yes I know Flash)


Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Stuart Dallas
On 19 Aug 2013, at 16:24, Matijn Woudt tijn...@gmail.com wrote:

 On Mon, Aug 19, 2013 at 5:20 PM, Stuart Dallas stu...@3ft9.com wrote:
 On 19 Aug 2013, at 15:56, Matijn Woudt tijn...@gmail.com wrote:
 
 
 On Mon, Aug 19, 2013 at 11:54 AM, Stuart Dallas stu...@3ft9.com wrote:
 On 19 Aug 2013, at 10:49, aesbovis aesbo...@gmail.com wrote:
 
  I know Javascript can solve it, but I don't want to use Js.
  Thank you all the same.
 
 I know you've had the right answer, but I think it's worth pointing out that 
 use of JSON in no way requires Javascript, despite its name.
 
 -Stuart
 
 
 You might want to explain how you convert form data to JSON without 
 javascript?
 
 PHP can do it. Ruby can do it. .NET can do it. Just because you want to use 
 JSON in a web browser where Javascript is the go-to method, doesn't mean JSON 
 requires Javascript.
 
 -Stuart
 
 
 
 Yes, of course they can do it, but then you first need to submit the POST 
 data (which he could not do because of the above). Javascript is more or less 
 the only way to do it (yes I know Flash….)

I wasn't speaking to his specific issue as that was solved by an earlier 
response. I was just commenting that the implied intrinsic link between JSON 
and Javascript in what he had said does not exist.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Tedd Sperling
On Aug 19, 2013, at 11:32 AM, Stuart Dallas stu...@3ft9.com wrote:
 I wasn't speaking to his specific issue as that was solved by an earlier 
 response. I was just commenting that the implied intrinsic link between JSON 
 and Javascript in what he had said does not exist.
 
 -Stuart

This is similar JAVA and JavaScript confusion -- even the college where I teach 
didn't know the difference.

For example, several years ago, they asked me if I could teach Java-JavaScript 
and I answered Sure, which one? The administrator stood there like a dog who 
just heard a high note and replied Yes, we want you to teach Java-JavaScript.

After I explained the difference, her next comment was Which one are you 
certified in?

She went from not knowing the difference to knowing that certification was 
required to teach it (whatever it was).

It's a wonder that anyone receives an education these days.

Cheers,

tedd

___
tedd sperling
tedd.sperl...@gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Robert Cummings

On 13-08-19 11:32 AM, Stuart Dallas wrote:

On 19 Aug 2013, at 16:24, Matijn Woudt tijn...@gmail.com wrote:


You might want to explain how you convert form data to JSON without javascript?


PHP can do it. Ruby can do it. .NET can do it. Just because you want to use 
JSON in a web browser where Javascript is the go-to method, doesn't mean JSON 
requires Javascript.

-Stuart



Yes, of course they can do it, but then you first need to submit the POST data 
(which he could not do because of the above). Javascript is more or less the 
only way to do it (yes I know Flash….)


I wasn't speaking to his specific issue as that was solved by an earlier 
response. I was just commenting that the implied intrinsic link between JSON 
and Javascript in what he had said does not exist.


Your post didn't in anyway indicate that your response had nothing to do 
with his problem:


I know you've had the right answer, but I think it's worth
 pointing out that use of JSON in no way requires Javascript,
 despite its name.

As such, given the requirement of POSTing over HTTP(S) and that 
JavaScript is almost certainly more frequently used than ActionScript, I 
think a JSON based solution was at least 50% linked to JavaScript.


:)

Cheers,
Rob
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I make PHP CodeSniffer Fixer ignore the namespace declaration?

2013-03-12 Thread ma...@behnke.biz
 Norah Jones nh.jone...@gmail.com hat am 12. März 2013 um 15:18 geschrieben:

 I am using the sublime text 2 plugin for PHP Coding Standards Fixer. It is
 working fine, except for the fact that it considers the namespace invalid (it
 is in fact invalid and I'm okay with it). this errors halts the script from
 correcting the rest of the file. I get the following error:

 The namespace Application\Controllers\Admin in  does not match the file
 path according to PSR-0 rules.

 How can I tell the the script to ignore the namespace constraint. Both command
 line arguments and Sublime text 2 user settings can be changed.

Have you looked at the configuration options? Do they help?

https://github.com/fabpot/PHP-CS-Fixer



--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Nilesh Govindarajan
On Thu 22 Sep 2011 08:25:29 PM IST, Eric wrote:
 I have this problem when using php because my computer recognizes
 the characters . and .. as an existing file when I use file_exists. Also
 I want to check $_POST[username] for characters other then A-Z a-z and 0-9.
 If it contains anything other then, I would like to prompt the user but
 I can't seam to use foreach properly and I don't know how to itterate
 through the post variable with a for loop while loop or do while loop.

file_exists() for . and .. would always return true, because they
really exist! . is an alias for the current directory and .. for the
parent directory. This is irrespective of OS.

To search $_POST[username] for characters other than A-Z, a-z, 0-9,
you can use preg_match something like this (there's an alpha class as
well, but I'm not sure about it):

if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) {
// string contains other characters, write the code
}

-- 
Nilesh Govindarajan
http://nileshgr.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Tommy Pham
On Thu, Sep 22, 2011 at 7:55 AM, Eric eric_justin_al...@cfl.rr.com wrote:

 I have this problem when using php because my computer recognizes
 the characters . and .. as an existing file when I use file_exists.
 Also
 I want to check $_POST[username] for characters other then A-Z a-z and
 0-9.
 If it contains anything other then, I would like to prompt the user but
 I can't seam to use foreach properly and I don't know how to itterate
 through the post variable with a for loop while loop or do while loop.


$pattern = '/^[A-Za-z0-9]/';
/* http://php.net/control-structures.foreach */
foreach ($_POST as $key = $value)
{
/* http://php.net/function.preg-match */
  if (preg_match($pattern, $value)  0)
  {
  /* prompt user */
  }
}


Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Igor Escobar
Use this regex:
if(preg_match('/[[:punct:]]/', $_POST['username']) !== 0) {
// string contains other characters, write the code
}

The POSIX class [:punct:] means matches any punctuation and symbols in your
string and that includes [!#$%'()*+,\-./:;=?@[\\\]^_`{|}~]


Regards,
Igor Escobar
*Software Engineer
*
+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar http://www.twitter.com/igorescobar





On Thu, Sep 22, 2011 at 9:17 AM, Nilesh Govindarajan
cont...@nileshgr.comwrote:

 On Thu 22 Sep 2011 08:25:29 PM IST, Eric wrote:
  I have this problem when using php because my computer recognizes
  the characters . and .. as an existing file when I use file_exists.
 Also
  I want to check $_POST[username] for characters other then A-Z a-z and
 0-9.
  If it contains anything other then, I would like to prompt the user but
  I can't seam to use foreach properly and I don't know how to itterate
  through the post variable with a for loop while loop or do while loop.

 file_exists() for . and .. would always return true, because they
 really exist! . is an alias for the current directory and .. for the
 parent directory. This is irrespective of OS.

 To search $_POST[username] for characters other than A-Z, a-z, 0-9,
 you can use preg_match something like this (there's an alpha class as
 well, but I'm not sure about it):

 if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) {
 // string contains other characters, write the code
 }

 --
 Nilesh Govindarajan
 http://nileshgr.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Igor Escobar
Or...  just use:

if(preg_match('/^[A-Za-z0-9]+$/', $_POST['username']) !== 0) {
// string contains other characters, write the code
}

You can see this regex in action here: http://regexpal.com/?flags=regex=
^%5BA-Za-z0-9%5D%2B%24input=myusername01

If you put anything different of A-Za-z0-9 the regex will not match.

Regards,
Igor Escobar
*Software Engineer
*
+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar http://www.twitter.com/igorescobar





On Thu, Sep 22, 2011 at 10:03 AM, Igor Escobar titiolin...@gmail.comwrote:

 Use this regex:
 if(preg_match('/[[:punct:]]/', $_POST['username']) !== 0) {

 // string contains other characters, write the code
 }

 The POSIX class [:punct:] means matches any punctuation and symbols in
 your string and that includes [!#$%'()*+,\-./:;=?@[\\\]^_`{|}~]


 Regards,
 Igor Escobar
 *Software Engineer
 *
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar http://www.twitter.com/igorescobar






 On Thu, Sep 22, 2011 at 9:17 AM, Nilesh Govindarajan cont...@nileshgr.com
  wrote:

 On Thu 22 Sep 2011 08:25:29 PM IST, Eric wrote:
  I have this problem when using php because my computer recognizes
  the characters . and .. as an existing file when I use file_exists.
 Also
  I want to check $_POST[username] for characters other then A-Z a-z and
 0-9.
  If it contains anything other then, I would like to prompt the user but
  I can't seam to use foreach properly and I don't know how to itterate
  through the post variable with a for loop while loop or do while loop.

 file_exists() for . and .. would always return true, because they
 really exist! . is an alias for the current directory and .. for the
 parent directory. This is irrespective of OS.

 To search $_POST[username] for characters other than A-Z, a-z, 0-9,
 you can use preg_match something like this (there's an alpha class as
 well, but I'm not sure about it):

 if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) {
 // string contains other characters, write the code
 }

 --
 Nilesh Govindarajan
 http://nileshgr.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Robert Williams
As an alternative to the regular expression approaches already provided by
others, you could also use ctype_alnum():

if (ctyp_alnum($_POST['username'])) {
   //username contains only letters and numbers
} else {
   //username contains characters other than letters and numbers
} //if-else

Docs: http://us3.php.net/manual/en/function.ctype-alnum.php


As a bonus, this will likely be quite a bit quicker than the regex-based
approaches. That said, you'd have to be making many calls (e.g., inside a
loop) for the difference to reach the point of being noticeable. For
something like a one-time validation on page-load, use whichever you find
most comfortable.

In your original question, you also mentioned looping through a variable
to check for non-alphanumeric characters. The regex approach or the
approach I outlined above is much better in this case, but as a learning
exercise, you could do the looping like this:

$validCharacters = array('a', 'e', 'i', 'o', 'u');
for ($i = 0; $i  count($_POST['username']); $i++) {
   if (in_array($_POST['username'][$i], $validCharacters)) {
  echo 'Pass!';
  } else {
  echo 'Fail!';
   } //if-else
} //for i

The key thing to note there is that you can treat the string like it's an
array to loop through it. For more information about this, go here:

http://us2.php.net/manual/en/language.types.string.php

and search the page for the phrase String access and modification by
character.







Regards,

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/


Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Nilesh Govindarajan
On 09/22/2011 10:36 PM, Robert Williams wrote:
 As an alternative to the regular expression approaches already provided by
 others, you could also use ctype_alnum():
 
 if (ctyp_alnum($_POST['username'])) {
//username contains only letters and numbers
 } else {
//username contains characters other than letters and numbers
 } //if-else
 
 Docs: http://us3.php.net/manual/en/function.ctype-alnum.php
 
 
 As a bonus, this will likely be quite a bit quicker than the regex-based
 approaches. That said, you'd have to be making many calls (e.g., inside a
 loop) for the difference to reach the point of being noticeable. For
 something like a one-time validation on page-load, use whichever you find
 most comfortable.
 
 In your original question, you also mentioned looping through a variable
 to check for non-alphanumeric characters. The regex approach or the
 approach I outlined above is much better in this case, but as a learning
 exercise, you could do the looping like this:
 
 $validCharacters = array('a', 'e', 'i', 'o', 'u');
 for ($i = 0; $i  count($_POST['username']); $i++) {
if (in_array($_POST['username'][$i], $validCharacters)) {
   echo 'Pass!';
   } else {
   echo 'Fail!';
} //if-else
 } //for i
 
 The key thing to note there is that you can treat the string like it's an
 array to loop through it. For more information about this, go here:
 
 http://us2.php.net/manual/en/language.types.string.php
 
 and search the page for the phrase String access and modification by
 character.
 
 

And if you want to go the loop way, you could use range() to fill values
in $validCharacters.
$validCharacters = array_merge(range('A', 'Z'), range('a', 'z'));


-- 
Nilesh Govindarajan
http://nileshgr.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Robert Williams
[Redirecting thread back to the list for the benefit of others.]

On 9/22/11 13:38, Eric eric_justin_al...@cfl.rr.com wrote:


So is $_POST[username][0] appropriate or does that only work
with normal variables?

As far as this sort of manipulation goes, $_POST is just like any other
variable. Referencing the 0th element of any string will give you the
first character, if there is one. (If there isn't one, you'll generate a
PHP warning or notice for trying to read out-of-bounds.)

and would this be valid,
$i = 0;
while($_POST[username][$i] != \0)

It looks like you're trying to treat the string as a C-style string. That
won't work in PHP because PHP's strings are not null-terminated. Thus,
this will lead to an infinite loop with any strings that don't happen to
have the null character somewhere within (and most strings won't).

{
if($_POST[username][$i] == . ||  $_POST[username][$i] == ..)

This line is not wrong per-se, but nor does it entirely make sense. When
you access a string as an array, each element contains one character.
Here, you're checking whether each character in turn is a period (fine) or
two periods (makes no sense, since one character cannot represent two
period characters). What you'd probably want to do is simply remove the
second condition, since a check for one period will work just as well if
the name contains two periods. That is:

   if($_POST[username][$i] == .)

Incidentally, another tip: when comparing against a constant, as you are
in both your while() and your if(), place the constant on the left side if
the expression rather than the right. That is, write the previous if()
like this:

   if ('.' == $_POST['username'])

It might look a little funny, but I assure you, someday, it'll save you a
bunch of frustrating debugging time. The reason is that if you mistype the
'==' as '=', you'll do an assignment, the value of which is then returned.
This has the net effect of 1) quietly changing your variable's value, and
2) making the overall expression always evaluate to true, sending you into
the the true part of the conditional branch, well, unconditionally.



--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/








Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I call GD's imagepng() directly from my class?

2010-12-07 Thread Richard Quadling
On 7 December 2010 07:19, Nathan Nobbe quickshif...@gmail.com wrote:
 On Mon, Dec 6, 2010 at 5:26 PM, Daevid Vincent dae...@daevid.com wrote:


 I got a little 'hack' further, but not loving it. Maybe I'll move the image
 to a $_SESSION variable and then have the gdtest.php pull it and echo it
 that way


 well i think you may be in the right direction, however, id be interested to
 see what others on the list think about this particular approach.
  personally, i wouldnt store an image in the session.. but i would certainly
 provision a temporary directory inside the webroot where you could put these
 images.

 perhaps if the images are tied to sessions, throw cleanup in a custom
 session cleanup cron, or queue the images for deletion when the user logs
 out.  seems to me like the session is an area of abuse in many php apps ive
 seen.  even though the standard store is file based, i would still recommend
 a separate store for images.



        public function render_image()
        {
                $my_img = imagecreate( 200, 80 );
                $background = imagecolorallocate( $my_img, 0, 0, 255 );
                $text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
                $line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
                imagestring( $my_img, 4, 30, 25, Test Image, $text_colour
 );
                imagesetthickness ( $my_img, 5 );
                imageline( $my_img, 30, 45, 165, 45, $line_colour );

                 ob_start();
                 header( Content-type: image/png );
                header('Content-Length: ' . strlen($my_img));
                imagepng( $my_img );
                 $final_image_data = ob_get_contents();
                ob_end_clean();

                imagecolordeallocate( $line_color );
                imagecolordeallocate( $text_color );
                imagecolordeallocate( $background );
                imagedestroy( $my_img );

                 echo
 'data:image/png;base64,'.base64_encode($final_image_data);
        }

 img src=?php $my_lopa-render_image(); ? width=200 height=80


 i dunno, why not just have something a bit simpler, where you generate an
 image and store it to disk.  the function could return the path where the
 image was saved.  then when the browser loads that resource php doesnt even
 fire up, the webserver just sends back the image directly.

 not sure on whether you would pass in the location or if you would have
 internal logic cook up the path, but im sure you could determine that based
 on the rest of the code .. lets suppose your class computes it internally,

 something like

 ?php
 class LOPA
 {
  private function get_temp_path()
  {
     // some session specific logic to cook up a temporary path
     // something relative to the web root ...
  }

  public function render_image()
  {
    $my_img = imagecreate( 200, 80 );

    $background = imagecolorallocate( $my_img, 0, 0, 255 );
    $text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
    $line_colour = imagecolorallocate( $my_img, 128, 255, 0 );

    imagestring( $my_img, 4, 30, 25, Test Image, $text_colour);
    imagesetthickness ( $my_img, 5 );
    imageline( $my_img, 30, 45, 165, 45, $line_colour );

    // now saving to a temp location inside the webroot
    $temp_path = $this-get_temp_path();
    imagepng( $my_img, $temp_path );

    imagecolordeallocate( $line_color );
    imagecolordeallocate( $text_color );
    imagecolordeallocate( $background );
    imagedestroy( $my_img );

    // returning path to temp location
    return $temp_path;
  }
 }
 ?

 !-- now this just has a path which points right back to an image, served
 directly --
 img src=?php $my_lopa-render_image(); ? width=200 height=80

 -nathan

I had a similar issue in generating a badge based upon various stats.

I found that there were many individuals who shared the same stats, so
the badge was the same. Even more advanced users often shared stats.

So, rather than creating an image per individual, I based the name of
the image on $md5BadgeData = md5(serialize($badgeData)).

So, main page loads and gathers the stats for person.

If the badge doesn't exist, then creates the PNG file.

Write out the HTML using img src=./badges/{$md5BadgeData}.png /

If a user's stats change, they'll have a new badge. Sure, there will
be orphaned badges, but they are tiny little things and I don't have
gazillion users.




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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I call GD's imagepng() directly from my class?

2010-12-06 Thread Nathan Nobbe
On Mon, Dec 6, 2010 at 5:01 PM, Daevid Vincent dae...@daevid.com wrote:

 I have a class that does some massive computations to compute a LOPA
 (layout of passenger aircraft).

 I currently render it in an HTML table with little seats. I want to now
 make this using GD so I can show entire fleets of aircraft on one page.

 Inside my LOPA.class.php I have this method:

public function render_image()
{
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, Test Image, $text_colour
 );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

header( Content-type: image/png );
header('Content-Length: ' . strlen($my_img));
imagepng( $my_img );

imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
}


 And I'm trying to call it from a PHP page like so:

 img src=?php $my_lopa-render_image(); ? alt=Image created by a PHP
 script width=200 height=80

 But it doesn't show the picture. :\

 If I take the contents of that function and dump it into a gdtest.php
 file and call it like this however, it does work:

 img src=images/gdtest.php alt=Image created by a PHP script
 width=200 height=80

 So what am I doing wrong above that I can't just call it from my class?


Your approach with the class should show as src= on your rendered web page
since the output from the function is binary meant for the browser, read:
not meant as content for an HTML attribute.

The later however is fine, since its text which references a php page.  What
happens when that is sent to the browser is it invokes images/gdtest.php on
your server, which outputs the binary directly to the browser.

If you want to use the class, you should do as your second example for the
tag itself, then inside of images/gdtest.php instantiate the class and call
the method.

gdtest.php

?php
 $oImgRenderer = new LOPA(); // or whatever your class is called
 $oImgRenderer-render_image();
?

-nathan


RE: [PHP] How can I call GD's imagepng() directly from my class?

2010-12-06 Thread Daevid Vincent
 

 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com] 
 Sent: Monday, December 06, 2010 4:02 PM
 To: php-general@lists.php.net
 Subject: [PHP] How can I call GD's imagepng() directly from my class?
 
 I have a class that does some massive computations to compute a LOPA
 (layout of passenger aircraft).
  
 I currently render it in an HTML table with little seats. I 
 want to now
 make this using GD so I can show entire fleets of aircraft on 
 one page.
  
 Inside my LOPA.class.php I have this method:
 
   public function render_image()
   {
   $my_img = imagecreate( 200, 80 );
   $background = imagecolorallocate( $my_img, 0, 0, 255 );
   $text_colour = imagecolorallocate( $my_img, 
 255, 255, 0 );
   $line_colour = imagecolorallocate( $my_img, 
 128, 255, 0 );
   imagestring( $my_img, 4, 30, 25, Test Image, 
 $text_colour
 );
   imagesetthickness ( $my_img, 5 );
   imageline( $my_img, 30, 45, 165, 45, $line_colour );
 
   header( Content-type: image/png );
   header('Content-Length: ' . strlen($my_img));
   imagepng( $my_img );
 
   imagecolordeallocate( $line_color );
   imagecolordeallocate( $text_color );
   imagecolordeallocate( $background );
   imagedestroy( $my_img );
   }
 
 
 And I'm trying to call it from a PHP page like so:
 
 img src=?php $my_lopa-render_image(); ? alt=Image 
 created by a PHP
 script width=200 height=80
 
 But it doesn't show the picture. :\
 
 If I take the contents of that function and dump it into a 
 gdtest.php
 file and call it like this however, it does work:
 
 img src=images/gdtest.php alt=Image created by a PHP script
 width=200 height=80
 
 So what am I doing wrong above that I can't just call it from 
 my class?
 

I got a little 'hack' further, but not loving it. Maybe I'll move the image
to a $_SESSION variable and then have the gdtest.php pull it and echo it
that way

public function render_image()
{
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, Test Image, $text_colour
);
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

ob_start();
header( Content-type: image/png );
header('Content-Length: ' . strlen($my_img));
imagepng( $my_img );
$final_image_data = ob_get_contents();
ob_end_clean();

imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );

echo
'data:image/png;base64,'.base64_encode($final_image_data);
}

img src=?php $my_lopa-render_image(); ? width=200 height=80



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I call GD's imagepng() directly from my class?

2010-12-06 Thread Nathan Nobbe
On Mon, Dec 6, 2010 at 5:26 PM, Daevid Vincent dae...@daevid.com wrote:


 I got a little 'hack' further, but not loving it. Maybe I'll move the image
 to a $_SESSION variable and then have the gdtest.php pull it and echo it
 that way


well i think you may be in the right direction, however, id be interested to
see what others on the list think about this particular approach.
 personally, i wouldnt store an image in the session.. but i would certainly
provision a temporary directory inside the webroot where you could put these
images.

perhaps if the images are tied to sessions, throw cleanup in a custom
session cleanup cron, or queue the images for deletion when the user logs
out.  seems to me like the session is an area of abuse in many php apps ive
seen.  even though the standard store is file based, i would still recommend
a separate store for images.



public function render_image()
{
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, Test Image, $text_colour
 );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

 ob_start();
 header( Content-type: image/png );
header('Content-Length: ' . strlen($my_img));
imagepng( $my_img );
 $final_image_data = ob_get_contents();
ob_end_clean();

imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );

 echo
 'data:image/png;base64,'.base64_encode($final_image_data);
}

 img src=?php $my_lopa-render_image(); ? width=200 height=80


i dunno, why not just have something a bit simpler, where you generate an
image and store it to disk.  the function could return the path where the
image was saved.  then when the browser loads that resource php doesnt even
fire up, the webserver just sends back the image directly.

not sure on whether you would pass in the location or if you would have
internal logic cook up the path, but im sure you could determine that based
on the rest of the code .. lets suppose your class computes it internally,

something like

?php
class LOPA
{
  private function get_temp_path()
  {
 // some session specific logic to cook up a temporary path
 // something relative to the web root ...
  }

  public function render_image()
  {
$my_img = imagecreate( 200, 80 );

$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );

imagestring( $my_img, 4, 30, 25, Test Image, $text_colour);
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

// now saving to a temp location inside the webroot
$temp_path = $this-get_temp_path();
imagepng( $my_img, $temp_path );

imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );

// returning path to temp location
return $temp_path;
  }
}
?

!-- now this just has a path which points right back to an image, served
directly --
img src=?php $my_lopa-render_image(); ? width=200 height=80

-nathan


Re: [PHP] How can I detect an exception without using try/catch?

2009-04-26 Thread kranthi
a POSSIBLE work round.

see if u can use
http://in2.php.net/manual/en/function.error-get-last.php or
http://in2.php.net/manual/en/reserved.variables.phperrormsg.php but
they are not working as expected with xdebug. use them in the
__destruct function to check for an uncaught exception

alternatively.. this approach is NOT RECOMMENDED. use it only if u run
out of options

keep the destructor empty. catch the exception and call a function to
perform destruction and then unset the object.
at the end of script, check if the object is set, call the function to
perform destruction. (php dosent destroy the object if the exception
is caught)

Kranthi.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread Andrea Giammarchi

http://uk2.php.net/set_exception_handler
http://uk2.php.net/manual/en/function.set-error-handler.php


 Date: Thu, 23 Apr 2009 12:19:30 -0400
 From: wmo...@potentialtech.com
 To: php-general@lists.php.net
 Subject: [PHP] How can I detect an exception without using try/catch?
 
 
 Specifically, the __destruct() method of certain objects will be
 called if an object goes out of scope due to an exception.  Since
 the __destruct() method didn't call the code that caused the
 exception, it can't catch it.
 
 I need the __destruct() method to behave differently if it's
 called while an exception is in progress than if it's called
 simply because the object is unset.
 
 Searches of the docs has yet to turn up anything and Google isn't
 helping.  Anyone have any pointers?
 
 -- 
 Bill Moran
 http://www.potentialtech.com
 http://people.collaborativefusion.com/~wmoran/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Re: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread 9el


 What would be nice is a function like get_current_exception() that
 would either return the current exception object, or return false
 if there is no exception.

 I guess the try catch pair works like this:

you  try to  run a part of script which you know it could be under errors

You tell your boy to play(but a bulley comes often):
try {
Go boy try to play
}

catch (street_bulley_came) {
do not cry or dont swear at the bulley dont be afraid
}

Lenin

www.twitter.com/nine_L


Re: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread Stuart
2009/4/23 Bill Moran wmo...@potentialtech.com:

 Specifically, the __destruct() method of certain objects will be
 called if an object goes out of scope due to an exception.  Since
 the __destruct() method didn't call the code that caused the
 exception, it can't catch it.

 I need the __destruct() method to behave differently if it's
 called while an exception is in progress than if it's called
 simply because the object is unset.

 Searches of the docs has yet to turn up anything and Google isn't
 helping.  Anyone have any pointers?

As far as I'm aware what you're asking for is not possible. Exception
handlers run without any context - check the return value from
debug_backtrace() in a catch block to see what I mean.

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread Bill Moran

Ok, the details of the problem obviously aren't being understood.
Let's assume that I explained it poorly and I'll try again.  Take the
following code (It's complete, cut/paste to see what happens.):

?php

class running {
 private $running;
 
 public function __construct() {
  $this-running = true;
 }
 
 public function stop() {
  $this-running = false;
 }
 
 public function __destruct() {
  if ($this-running) {
   throw new exception('I have not stopped running yet!');
  }
 }
}

function fail_horribly() {
 throw new exception('This is the real error that I want a stack trace from');
}

function do_that_thing() {
  $running = new running();
  fail_horribly();
  $running-stop();
}

try {
 do_that_thing();
}
catch (exception $e) {
 echo $e-getMessage();
}

?

While putting this together, I discovered lots of interesting
behaviour.  Depending on exactly where I put the try/catch, there are
different things that happen and different errors that occur.  It's
kinda interesting.

The thing is, that none of those errors is the result that I _want_
which is to ignore the fact that $running was unset and just report
the error that started everything going wrong.

If I could put my fictional function (get_current_exception()) in the
__destruct() method, I could detect that an exception was already in
progress and avoid throwing another one.

-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread Andrea Giammarchi

uhm, I did not read it, you are right ... well, take this code as a joke, OK?

?php
function exception_handler($exception) {
echo Error:  , $exception-getMessage(), \n;
if($checkSomethingAndEventuallyContinue = true){
$line = $exception-getLine();
$php = explode(PHP_EOL, file_get_contents($exception-getFile()));
while($line--)
array_shift($php);
eval(implode(PHP_EOL, $php));
}
}

set_exception_handler('exception_handler');
throw new Exception('Uncaught Exception');
echo Not Executed\n;
?


 Date: Fri, 24 Apr 2009 07:07:10 -0400
 From: wmo...@potentialtech.com
 To: an_...@hotmail.com
 CC: php-general@lists.php.net
 Subject: Re: [PHP] How can I detect an exception without using try/catch?
 
 In response to Andrea Giammarchi an_...@hotmail.com:
  
  http://uk2.php.net/set_exception_handler
  http://uk2.php.net/manual/en/function.set-error-handler.php
 
 Thanks for the reply, Andrea.  However, you either didn't read my
 entire message, or didn't understand it.  I can't use either of
 those to detect an exception that's already in progress, I can only
 use them to catch the exception before the script ends if nothing
 else catches it.
 
 What would be nice is a function like get_current_exception() that
 would either return the current exception object, or return false
 if there is no exception.
 
   Date: Thu, 23 Apr 2009 12:19:30 -0400
   From: wmo...@potentialtech.com
   To: php-general@lists.php.net
   Subject: [PHP] How can I detect an exception without using try/catch?
   
   
   Specifically, the __destruct() method of certain objects will be
   called if an object goes out of scope due to an exception.  Since
   the __destruct() method didn't call the code that caused the
   exception, it can't catch it.
   
   I need the __destruct() method to behave differently if it's
   called while an exception is in progress than if it's called
   simply because the object is unset.
   
   Searches of the docs has yet to turn up anything and Google isn't
   helping.  Anyone have any pointers?
   
   -- 
   Bill Moran
   http://www.potentialtech.com
   http://people.collaborativefusion.com/~wmoran/
   
   -- 
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
   
  
  _
  Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
  
  http://www.microsoft.com/windows/windowslive/products/photos.aspx
 
 
 -- 
 Bill Moran
 http://www.potentialtech.com
 http://people.collaborativefusion.com/~wmoran/

_
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx

Re: [PHP] How can I detect an exception without using try/catch?

2009-04-24 Thread Bill Moran
In response to Andrea Giammarchi an_...@hotmail.com:
 
 http://uk2.php.net/set_exception_handler
 http://uk2.php.net/manual/en/function.set-error-handler.php

Thanks for the reply, Andrea.  However, you either didn't read my
entire message, or didn't understand it.  I can't use either of
those to detect an exception that's already in progress, I can only
use them to catch the exception before the script ends if nothing
else catches it.

What would be nice is a function like get_current_exception() that
would either return the current exception object, or return false
if there is no exception.

  Date: Thu, 23 Apr 2009 12:19:30 -0400
  From: wmo...@potentialtech.com
  To: php-general@lists.php.net
  Subject: [PHP] How can I detect an exception without using try/catch?
  
  
  Specifically, the __destruct() method of certain objects will be
  called if an object goes out of scope due to an exception.  Since
  the __destruct() method didn't call the code that caused the
  exception, it can't catch it.
  
  I need the __destruct() method to behave differently if it's
  called while an exception is in progress than if it's called
  simply because the object is unset.
  
  Searches of the docs has yet to turn up anything and Google isn't
  helping.  Anyone have any pointers?
  
  -- 
  Bill Moran
  http://www.potentialtech.com
  http://people.collaborativefusion.com/~wmoran/
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 _
 Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
 
 http://www.microsoft.com/windows/windowslive/products/photos.aspx


-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)RESOLVED

2009-04-10 Thread Terion Miller
Thanks
Terion

Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
Report Moderator Abuse Here:
http://www.freecycle.org/faq/faq/contact-info
Or Email Your Complaint to:
f...@freecycle.org or i...@freecycle.org

Twitter?
http://twitter.com/terionmiller

Facebook:
a href=http://www.facebook.com/people/Terion-Miller/1542024891;
title=Terion Miller's Facebook profile target=_TOPimg src=
http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
alt=Terion Miller's Facebook profile/a


On Wed, Apr 8, 2009 at 7:43 PM, Raymond Irving xwis...@yahoo.com wrote:


 For me its very easy to pass php values to the client:

 echo _var($value,'name');

 But the best part is taking control of what your client sees from the
 server-side:

 C('#info')-show(); // now you see it
 ...
 C('#info')-hide(); // now you don't!

 Take control and start building powerful web apps with Raxan PDI -
 http://raxanpdi.com

 __
 Raymond Irving
 Create Rich Ajax/PHP Web Apps today!
 Raxan PDI - http://raxanpdi


 --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:

  From: Michael A. Peters mpet...@mac.com
  Subject: Re: [PHP] How can I echo a javascript var in an email subject
 line? Possible?
  To: Terion Miller webdev.ter...@gmail.com
  Cc: PHP General php-general@lists.php.net
  Date: Wednesday, April 8, 2009, 2:34 PM
  Terion Miller wrote:
  
  
  
  
   On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters
  mpet...@mac.com
  mailto:mpet...@mac.com
  wrote:
  
   Terion Miller wrote:
  
  
  
  javascript is
  client side.
  php is server
  side.
  To use
  something client side in a server side script, the web
   page
  has to send
  it to the server from the client.
  
  The best way
  to do what you want to do is probably to do the work
  count server
  side, but if you really want to use what javascript
  produced you
  can create a hidden input with a specified id,
   and use
  dhtml via
  javascript to modify the input and insert the value
   into
  the value
  field of the hidden input. Then it will get sent to the
  server when
  the user hits the post button.
  
  However,
  since you should be validating any user input server
   side,
  you'll need
  to validate that the variable is accurate - might as
  well just do
  the count with php server side.
  
  
  
   Thanks Michael I
  was kind of moving in the right direction as
   far as the
  hidden input goes, going to have to google on how to
   do it with the
  dhtml and all like you suggested.
  
  
   Look at the various DOM
  functions - IE for
  
   input type=hidden
  name=wordcount id=hiddenStudd value=
  
   you coud do in your js:
  
   var myHidden =
  document.getElementById('hiddenStuff');
  
 myHidden.setAttribute('value',$yourvalue);
  
  
   Thought I would go ahead and post a bit more on this,
  so here is my wordcount little function on the textarea of
  the form:
  
   textarea name=Comments
  cols=55 rows=5 wrap=hard
  onKeyDown=wordCounter(this.form.Comments,this.form.remLen,
  300);
  onKeyUp=wordCounter(this.form.Comments,this.form.remLen,
  300);?php if (isset($_SESSION['Comments'])) {echo
  $_SESSION['Comments'];}
  ?/textareabrLetters to the Editor are
  limited to 300 words or less.brWords remaining:
  input type=box readonly name=remLen size=3
  value=300
  
   So I was thinking I should be able to pass that again
  to the next page which is the emailform.php page that is
  taking all the id= and printing them to an email 
   should be able to reuse that function right?
  
   input type=hidden id=words  value=
  onSubmit=return
  wordCounter(this.form.Comments,this.form.remLen); 
  
   or do I need to define the variable? think I'm
  starting to confuse myself lol
 
  You don't want the onSubmit in the the hidden input.
 
  I'm not a javascript guru - but I believe you can have the
  form onSubmit do the word count and insert it into the input
  field before the actual submit happens, I've never tried
  having an onsubmit function alter a value field though.
 
  I would change the textarea to have an id=Comments field
  and the remLen input to have an id=remLen field to make it
  easy to find via getElementById (as id attributes have to be
  unique), count the words and set them to a variable that
  then gets put into the hidden input before whatever function
  you run on the submit type onSubmit returns true.
 
  not tested - but something like this:
 
  function countTheWords() {
 var comment =
  $document.getElementById('Comments');
 var remLen  =
  $document.getElementById('remLen').value;
 var count =
  wordCounter

Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-09 Thread tedd

At 1:00 PM -0500 4/8/09, Terion Miller wrote:

Thought I would go ahead and post a bit more on this, so here is my
wordcount little function on the textarea of the form:


-snip-


or do I need to define the variable? think I'm starting to confuse myself
lol


The reason why you are starting to confuse yourself is that you are 
still considering doing some part of this by including javascript in 
the solution -- there is NO need.


Just receive what the user submits and process it server-side before 
mailing -- pure and simple.


That way not only can you clean the submission, but you can count the 
words and put that count in the subject line like you wanted. This 
really a simple problem. You are complicating it by including 
javascript.


Cheers,

tedd

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-08 Thread Michael A. Peters

Terion Miller wrote:

I have a php form, that uses a javascript word counter to make sure
submissions are a certain number of words, I have now been tasked with
taking that word count and having it pass in the email that gets sent when
someone submits a form ..in the subject line.
Here is the code I'm using so far.  Is it possible to just echo a
javascript  variable on a page like you can a php var?


javascript is client side.
php is server side.
To use something client side in a server side script, the web page has 
to send it to the server from the client.


The best way to do what you want to do is probably to do the work count 
server side, but if you really want to use what javascript produced you 
can create a hidden input with a specified id, and use dhtml via 
javascript to modify the input and insert the value into the value field 
of the hidden input. Then it will get sent to the server when the user 
hits the post button.


However, since you should be validating any user input server side, 
you'll need to validate that the variable is accurate - might as well 
just do the count with php server side.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-08 Thread Terion Miller
javascript is client side.
 php is server side.
 To use something client side in a server side script, the web page has to
 send it to the server from the client.

 The best way to do what you want to do is probably to do the work count
 server side, but if you really want to use what javascript produced you can
 create a hidden input with a specified id, and use dhtml via javascript to
 modify the input and insert the value into the value field of the hidden
 input. Then it will get sent to the server when the user hits the post
 button.

 However, since you should be validating any user input server side, you'll
 need to validate that the variable is accurate - might as well just do the
 count with php server side.



Thanks Michael I was kind of moving in the right direction as far as the
hidden input goes, going to have to google on how to do it with the dhtml
and all like you suggested.

Thanks


Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-08 Thread Michael A. Peters

Terion Miller wrote:



javascript is client side.
php is server side.
To use something client side in a server side script, the web page
has to send it to the server from the client.

The best way to do what you want to do is probably to do the work
count server side, but if you really want to use what javascript
produced you can create a hidden input with a specified id, and use
dhtml via javascript to modify the input and insert the value into
the value field of the hidden input. Then it will get sent to the
server when the user hits the post button.

However, since you should be validating any user input server side,
you'll need to validate that the variable is accurate - might as
well just do the count with php server side.



Thanks Michael I was kind of moving in the right direction as far as the 
hidden input goes, going to have to google on how to do it with the 
dhtml and all like you suggested.


Look at the various DOM functions - IE for

input type=hidden name=wordcount id=hiddenStudd value=

you coud do in your js:

var myHidden = document.getElementById('hiddenStuff');
myHidden.setAttribute('value',$yourvalue);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-08 Thread Terion Miller
On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com wrote:

 Terion Miller wrote:



javascript is client side.
php is server side.
To use something client side in a server side script, the web page
has to send it to the server from the client.

The best way to do what you want to do is probably to do the work
count server side, but if you really want to use what javascript
produced you can create a hidden input with a specified id, and use
dhtml via javascript to modify the input and insert the value into
the value field of the hidden input. Then it will get sent to the
server when the user hits the post button.

However, since you should be validating any user input server side,
you'll need to validate that the variable is accurate - might as
well just do the count with php server side.



 Thanks Michael I was kind of moving in the right direction as far as the
 hidden input goes, going to have to google on how to do it with the dhtml
 and all like you suggested.


 Look at the various DOM functions - IE for

 input type=hidden name=wordcount id=hiddenStudd value=

 you coud do in your js:

 var myHidden = document.getElementById('hiddenStuff');
 myHidden.setAttribute('value',$yourvalue);


Thought I would go ahead and post a bit more on this, so here is my
wordcount little function on the textarea of the form:

textarea name=Comments cols=55 rows=5 wrap=hard
onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300);
onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if
(isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];}
?/textareabrLetters to the Editor are limited to 300 words or
less.brWords remaining: input type=box readonly name=remLen size=3
value=300

So I was thinking I should be able to pass that again to the next page which
is the emailform.php page that is taking all the id= and printing them to an
email 
should be able to reuse that function right?

input type=hidden id=words  value= onSubmit=return
wordCounter(this.form.Comments,this.form.remLen); 

or do I need to define the variable? think I'm starting to confuse myself
lol


Re: [PHP] How can I echo a javascript var in an email subject line? Possible?

2009-04-08 Thread Michael A. Peters

Terion Miller wrote:





On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com 
mailto:mpet...@mac.com wrote:


Terion Miller wrote:



   javascript is client side.
   php is server side.
   To use something client side in a server side script, the web
page
   has to send it to the server from the client.

   The best way to do what you want to do is probably to do the work
   count server side, but if you really want to use what javascript
   produced you can create a hidden input with a specified id,
and use
   dhtml via javascript to modify the input and insert the value
into
   the value field of the hidden input. Then it will get sent to the
   server when the user hits the post button.

   However, since you should be validating any user input server
side,
   you'll need to validate that the variable is accurate - might as
   well just do the count with php server side.



Thanks Michael I was kind of moving in the right direction as
far as the hidden input goes, going to have to google on how to
do it with the dhtml and all like you suggested.


Look at the various DOM functions - IE for

input type=hidden name=wordcount id=hiddenStudd value=

you coud do in your js:

var myHidden = document.getElementById('hiddenStuff');
myHidden.setAttribute('value',$yourvalue);


Thought I would go ahead and post a bit more on this, so here is my 
wordcount little function on the textarea of the form:


textarea name=Comments cols=55 rows=5 wrap=hard 
onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); 
onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php 
if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} 
?/textareabrLetters to the Editor are limited to 300 words or 
less.brWords remaining: input type=box readonly name=remLen size=3 
value=300


So I was thinking I should be able to pass that again to the next page 
which is the emailform.php page that is taking all the id= and printing 
them to an email 

should be able to reuse that function right?

input type=hidden id=words  value= onSubmit=return 
wordCounter(this.form.Comments,this.form.remLen); 


or do I need to define the variable? think I'm starting to confuse 
myself lol


You don't want the onSubmit in the the hidden input.

I'm not a javascript guru - but I believe you can have the form onSubmit 
do the word count and insert it into the input field before the actual 
submit happens, I've never tried having an onsubmit function alter a 
value field though.


I would change the textarea to have an id=Comments field and the 
remLen input to have an id=remLen field to make it easy to find via 
getElementById (as id attributes have to be unique), count the words and 
set them to a variable that then gets put into the hidden input before 
whatever function you run on the submit type onSubmit returns true.


not tested - but something like this:

function countTheWords() {
   var comment = $document.getElementById('Comments');
   var remLen  = $document.getElementById('remLen').value;
   var count = wordCounter($comment,$remLen);
   var myHidden = document.getElementById('words');
   myHidden.setAttribute('value',$count);
   }

Then in whatever function you run in the form onSumbit have it run the 
countTheWords() function before it exits.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)

2009-04-08 Thread Raymond Irving

For me its very easy to pass php values to the client:

echo _var($value,'name');

But the best part is taking control of what your client sees from the 
server-side:

C('#info')-show(); // now you see it
...
C('#info')-hide(); // now you don't!

Take control and start building powerful web apps with Raxan PDI - 
http://raxanpdi.com

__
Raymond Irving
Create Rich Ajax/PHP Web Apps today!
Raxan PDI - http://raxanpdi


--- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:

 From: Michael A. Peters mpet...@mac.com
 Subject: Re: [PHP] How can I echo a javascript var in an email subject line? 
 Possible?
 To: Terion Miller webdev.ter...@gmail.com
 Cc: PHP General php-general@lists.php.net
 Date: Wednesday, April 8, 2009, 2:34 PM
 Terion Miller wrote:
  
  
  
  
  On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters
 mpet...@mac.com
 mailto:mpet...@mac.com
 wrote:
  
      Terion Miller wrote:
  
  
  
             javascript is
 client side.
             php is server
 side.
             To use
 something client side in a server side script, the web
          page
             has to send
 it to the server from the client.
  
             The best way
 to do what you want to do is probably to do the work
             count server
 side, but if you really want to use what javascript
             produced you
 can create a hidden input with a specified id,
          and use
             dhtml via
 javascript to modify the input and insert the value
          into
             the value
 field of the hidden input. Then it will get sent to the
             server when
 the user hits the post button.
  
             However,
 since you should be validating any user input server
          side,
             you'll need
 to validate that the variable is accurate - might as
             well just do
 the count with php server side.
  
  
  
          Thanks Michael I
 was kind of moving in the right direction as
          far as the
 hidden input goes, going to have to google on how to
          do it with the
 dhtml and all like you suggested.
  
  
      Look at the various DOM
 functions - IE for
  
      input type=hidden
 name=wordcount id=hiddenStudd value=
  
      you coud do in your js:
  
      var myHidden =
 document.getElementById('hiddenStuff');
  
    myHidden.setAttribute('value',$yourvalue);
  
  
  Thought I would go ahead and post a bit more on this,
 so here is my wordcount little function on the textarea of
 the form:
  
      textarea name=Comments
 cols=55 rows=5 wrap=hard
 onKeyDown=wordCounter(this.form.Comments,this.form.remLen,
 300);
 onKeyUp=wordCounter(this.form.Comments,this.form.remLen,
 300);?php if (isset($_SESSION['Comments'])) {echo
 $_SESSION['Comments'];}
 ?/textareabrLetters to the Editor are
 limited to 300 words or less.brWords remaining:
 input type=box readonly name=remLen size=3
 value=300
  
  So I was thinking I should be able to pass that again
 to the next page which is the emailform.php page that is
 taking all the id= and printing them to an email 
  should be able to reuse that function right?
  
  input type=hidden id=words  value=
 onSubmit=return
 wordCounter(this.form.Comments,this.form.remLen); 
  
  or do I need to define the variable? think I'm
 starting to confuse myself lol
 
 You don't want the onSubmit in the the hidden input.
 
 I'm not a javascript guru - but I believe you can have the
 form onSubmit do the word count and insert it into the input
 field before the actual submit happens, I've never tried
 having an onsubmit function alter a value field though.
 
 I would change the textarea to have an id=Comments field
 and the remLen input to have an id=remLen field to make it
 easy to find via getElementById (as id attributes have to be
 unique), count the words and set them to a variable that
 then gets put into the hidden input before whatever function
 you run on the submit type onSubmit returns true.
 
 not tested - but something like this:
 
 function countTheWords() {
    var comment =
 $document.getElementById('Comments');
    var remLen  =
 $document.getElementById('remLen').value;
    var count =
 wordCounter($comment,$remLen);
    var myHidden =
 document.getElementById('words');
    myHidden.setAttribute('value',$count);
    }
 
 Then in whatever function you run in the form onSumbit have
 it run the countTheWords() function before it exits.
 
 -- 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



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-06 Thread Alpár Török
2009/2/6 Daevid Vincent dae...@daevid.com

 Is there a way to use the default values of a function without
 specifying every single one until the parameter you want to modify in
 PHP5 ?

 I don't see it here, but feel this would be very useful indeed.
 http://www.php.net/manual/en/functions.arguments.php

 So given a function that takes seven parameters, I want to change one of
 them and leave the other defaults alone...

 ?php
 function SQL_QUERY($sql, $parameters = null, $showSQL = false,
 $showErrors = true, $execute = true, $noHTML = false, $profile = 0)
 {
var_dump($sql, $parameters, $showSQL, $showErrors, $execute,
 $noHTML,
 $profile);
 }
 ?

 pre
 ?php SQL_QUERY('SELECT * FROM foo WHERE bar = ?'); ?
 /pre
 hr
 pre
 ?php SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'),
 true); ?
 /pre
 hr
 pre
 ?php SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'),
 $execute=false); ?
 /pre

 outputs:
 ---
 string(31) SELECT * FROM foo WHERE bar = ?
 NULL
 bool(false)
 bool(true)
 bool(true)
 bool(false)
 int(0)
 ---
 string(31) SELECT * FROM foo WHERE bar = ?
 array(1) {  [0]=  string(4) beep }
 bool(true)
 bool(true)
 bool(true)
 bool(false)
 int(0)
 ---
 string(31) SELECT * FROM foo WHERE bar = ?
 array(1) {  [0]=  string(4) beep }
 bool(false)
 bool(true)
 bool(true)  -- I would have expected this one to be bool(false)
 bool(false)
 int(0)

 The above function call doesn't error out on me, it just seems it
 doesn't do anything either :-\

 So it seems I have to do this verboseness (AND know what the default
 values are to begin with too):

 SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'), false, true,
 false, false);

 Just to change one default parameter?!? :-(




You could probably create  a class and break up the functionality of that
function, for somebody reading your code would be hard understanding all
that parameters, maybe even for you after a while.


-- 
Alpar Torok


Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-06 Thread Daevid Vincent
On Fri, 2009-02-06 at 14:10 +1300, German Geek wrote:

 I've thought about this problem before but couldn't think of a
 solution either. 


Well, I guess I *did* think of a solution, it just happens that PHP
doesn't do the logical thing(tm) 

;-)

I would hope the PHP developers would implement this idea for a future
version. The concept is simple, just specify which parameters in the
function call you want to change and leave the others as their default.

I've added it here: http://bugs.php.net/bug.php?id=47331 with comments
about similar/related bugs.

Feel free to vote on this. I think it's a necessary addition to the
language and often a source of frustration for me in large projects
especially where functions get older and older and more parameters are
needed to maintain backwards compatibility yet get new functionality
too.




RE: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-06 Thread Boyd, Todd M.
 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com]
 Sent: Friday, February 06, 2009 2:26 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How can I use a function's default arguments but
 change one of the end ones in the list?
 
 On Fri, 2009-02-06 at 14:10 +1300, German Geek wrote:
 
  I've thought about this problem before but couldn't think of a
  solution either.
 
 
 Well, I guess I *did* think of a solution, it just happens that PHP
 doesn't do the logical thing(tm)
 
 ;-)
 
 I would hope the PHP developers would implement this idea for a future
 version. The concept is simple, just specify which parameters in the
 function call you want to change and leave the others as their
default.
 
 I've added it here: http://bugs.php.net/bug.php?id=47331 with comments
 about similar/related bugs.
 
 Feel free to vote on this. I think it's a necessary addition to the
 language and often a source of frustration for me in large projects
 especially where functions get older and older and more parameters are
 needed to maintain backwards compatibility yet get new functionality
 too.

Just tell 'em that .NET already has it; that'll light a fire under them!
:D
C# can do function calls like:

FunctionName(VariableName:=Value);

I wholeheartedly prefer PHP to .NET for most things... but you've got to
admit--that's a pretty slick feature. Me likey.


// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-06 Thread Frank Stanovcak

Boyd, Todd M. tmbo...@ccis.edu wrote in message 
news:33bde0b2c17eef46acbe00537cf2a19003d07...@exchcluster.ccis.edu...
 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com]
 Sent: Friday, February 06, 2009 2:26 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How can I use a function's default arguments but
 change one of the end ones in the list?

 On Fri, 2009-02-06 at 14:10 +1300, German Geek wrote:

  I've thought about this problem before but couldn't think of a
  solution either.


 Well, I guess I *did* think of a solution, it just happens that PHP
 doesn't do the logical thing(tm)

 ;-)

 I would hope the PHP developers would implement this idea for a future
 version. The concept is simple, just specify which parameters in the
 function call you want to change and leave the others as their
default.

 I've added it here: http://bugs.php.net/bug.php?id=47331 with comments
 about similar/related bugs.

 Feel free to vote on this. I think it's a necessary addition to the
 language and often a source of frustration for me in large projects
 especially where functions get older and older and more parameters are
 needed to maintain backwards compatibility yet get new functionality
 too.

Just tell 'em that .NET already has it; that'll light a fire under them!
:D
C# can do function calls like:

FunctionName(VariableName:=Value);

I wholeheartedly prefer PHP to .NET for most things... but you've got to
admit--that's a pretty slick feature. Me likey.


// Todd

I don't remember what it was I was using, but I remember a lang that allowed 
func(,,,change,,,change) where all the empty comas just went to default. 
*shrug* 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread Daniel Brown
On Thu, Feb 5, 2009 at 18:50, Daevid Vincent dae...@daevid.com wrote:
 Is there a way to use the default values of a function without
 specifying every single one until the parameter you want to modify in
 PHP5 ?

Daevid,

Check out func_get_args(): http://php.net/func_get_args

Then you can rename your sql_query() function to real_sql_query()
and create a new sql_query() as a wrapper function with
func_get_args() in place of statically-defined variables.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread German Geek
I've thought about this problem before but couldn't think of a solution
either. How does func_get_args() solve this? You could make a wrapper
function without that.

How would u (php) know which parameter u mean in a particular case?

I think it would just be useful to have an IDE that can write out the
default parameters on a keyboard shortcut or mouse click and then u can
change them afterwards.

Cheers,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 1:56 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Feb 5, 2009 at 18:50, Daevid Vincent dae...@daevid.com wrote:
  Is there a way to use the default values of a function without
  specifying every single one until the parameter you want to modify in
  PHP5 ?

 Daevid,

Check out func_get_args(): http://php.net/func_get_args

Then you can rename your sql_query() function to real_sql_query()
 and create a new sql_query() as a wrapper function with
 func_get_args() in place of statically-defined variables.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find
 out!

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread Jim Lucas
Daevid Vincent wrote:
 Is there a way to use the default values of a function without
 specifying every single one until the parameter you want to modify in
 PHP5 ?
 
 I don't see it here, but feel this would be very useful indeed.
 http://www.php.net/manual/en/functions.arguments.php
 
 So given a function that takes seven parameters, I want to change one of
 them and leave the other defaults alone...
 
  The above function call doesn't error out on me, it just seems it
 doesn't do anything either :-\
 
 So it seems I have to do this verboseness (AND know what the default
 values are to begin with too):
 
 SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'), false, true,
 false, false);
 
 Just to change one default parameter?!? :-(
 


What you are wanting to do is not possible.

Back in the day, I worked on a project that used our own variation of this type 
of functionality.

We had this function that helped a little


function alternate($a, $b) {
return $a = ( $a ? $a : $b );
}



function query($sql, $params=array()) {
alternate($params,  array());
extract($params);

alternate($parameters,  null);
alternate($showSQL, false);
alternate($showErrors,  true);
alternate($execute, true);
alternate($noHTML,  false);
alternate($profile, 0);

# Do your thing...

}

This allowed for us to include/exclude whatever we wanted from the

it is a little long winded to get to what you are looking for ( I think )


But it worked for us.




-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread Shawn McKenzie
German Geek wrote:
 I've thought about this problem before but couldn't think of a solution
 either. How does func_get_args() solve this? You could make a wrapper
 function without that.
 
 How would u (php) know which parameter u mean in a particular case?
 
 I think it would just be useful to have an IDE that can write out the
 default parameters on a keyboard shortcut or mouse click and then u can
 change them afterwards.
 
 Cheers,
 Tim
 
 Tim-Hinnerk Heuer
 
 http://www.ihostnz.com
 

Well, using func_get_args() you can pass whatever you want and parse the
args to see what was passed and assign default values if a specific arg
wasn't passed.

I however would probably pass an associative array to the func and parse
that.
-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread Daniel Brown
On Thu, Feb 5, 2009 at 20:10, German Geek geek...@gmail.com wrote:
 I've thought about this problem before but couldn't think of a solution
 either. How does func_get_args() solve this? You could make a wrapper
 function without that.

It's all in how it's used.  Ironically, I don't remember saying
that you couldn't make a wrapper function without it, or that it was
required to make a wrapper.  Thanks for clarifying that for everyone
just in case.  ;-P

 How would u (php) know which parameter u mean in a particular case?

You don't have to.  You can send NULL or empty strings for that
matter, and use the parameter position in func_get_args() that way.
Or using hierarchy and preference:

?php
if(func_num_args() == '2') {
$first_param = func_get_args(1);
$second_param = 'default_value';
$third_param = func_get_args(2);
$fourth_param = 'another default here';
}
?

Though inelegant, it works.

What would probably be better, though, would be to write the
wrapper as I mentioned, but have it accept a single parameter as an
array, like so:

?php
function wrapper_func($arr) {
// Define variable defaults
$param_one = null;
$param_two = 'apple';
$param_three = 'foo';
$param_four = 123.45;

// Redefine variables with values passed to __FUNCTION__
foreach($arr as $k = $v) {
$$k = $v;
}

// Call original function with these values and pass through the results.
return orig_func($param_one,$param_two,$param_three,$param_four);
}

// Then use it like so:
$params = array(
'param_two' = 'Orange',
'param_four' = 543.21,
);
?

If all orig_func() did was a simple foreach()/echo routine, it
wrapper_func() would print:

[NULL]
Orange
foo
543.21

 I think it would just be useful to have an IDE that can write out the
 default parameters on a keyboard shortcut or mouse click and then u can
 change them afterwards.

It would be nice if every programmer touching the code had the
same IDE.  Unfortunately, it's just not practical.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?

2009-02-04 Thread Stuart
2009/2/3 Daevid Vincent dae...@daevid.com:
 On Wed, 2009-02-04 at 08:58 +1100, Chris wrote:

  the question is what is __set() doing, if it's throwing an exception
  for undefined properties then obviously it with 'blow up'.
 
 
 
  But why should __set() even be called if I'm accessing the property
  directly? This seems stupid.
 
  $this-oraclecustomerid =  1122;
 
  should NOT be the same as
 
  $this-set_oraclecustomerid(1122);
 
  The second one I agree should call __set(), but the first one should NOT
  be triggering __call() or __set()

 Yes it should.

 http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members

 __set() is run when writing data to inaccessible members.

 if it's a protected/private variable, it'll call __set.

 If it's a variable that doesn't exist, it'll call __set.



 Let me rephrase that. I see now that it is designed that way, but I
 think the logic is erroneous.  While I'm sure this argument/discussion
 is all for naught now, I believe that a straight assignment of a value
 to a variable, SHOULD NOT do any behind the scenes magic __set(). It
 should just do it. Otherwise, what's the point of being able to set a
 property/variable both ways? One gives no benefit over the other and as
 illustrated decreases flexibility. It appears it will work if I change
 my property to public, but I don't want them exposed like that. *sigh*

 Bottom line is there should be a create_property($name, $value = null,
 $type = 'protected') function/method that I can call to do what I'm
 trying to do.

 I assume unset($this-foo); works. So therefore, I can check for
 existence of a property, and consequently remove a property, but I
 cannot create a property.

In PHP class properties must be defined before being used. The __set
and __get magic methods allow you to arbitrarily create properties,
and IMHO is the most flexible way to do it. If it just worked as you
want it to you would not be able to create rules around what
properties can be created or what values they can hold.

I use those magic methods to implement validation in my model classes.
If $this-x simply created x I would have to implement it using
accessor functions which IMHO is much less intuitive.

When deciding whether to call __set or __get PHP looks at whether you
can access the property in the current context, so if you declare a
private or protected property you should be able to set its value from
within the class without involving the magic methods.

Hope that makes things a bit clearer.

-Stuart

-- 
http://stut.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?

2009-02-03 Thread Jochem Maas
Edmund Hertle schreef:
 2009/2/3 Daevid Vincent dae...@daevid.com
 
 Is there a way to create a new property via PHP 5.2.4?

 I get a hash back from an authentication server. I'm not guaranteed that
 someone in another department won't add new key/values to the returned
 hash/array. I'm trying to work around that part gracefully so that the
 code doesn't blow up on a customer in such an event. The main try/catch
 will suppress errors already, but I thought it would be nice to be able
 to handle this stuff automatically rather than constantly updating a
 User.class.php file all the time.

creating new property this-oraclecustomerid with 1122

 but when I try to set the value with the $this-$pkey = $value;

 It triggers __call() which then triggers __set() which throws my
 BadProperty exception.

 How come $this-$pkey = $value isn't creating/setting a property?
 Or how do I do something like create_property($this, $pkey);
 so that I can then set it via $this-oraclecustomerid = 1122 or
 $this-set_oraclecustomerid(1122) ???

 ?php
 function load_from_user_data($user_data)
 {
//now loop through the rest of the user_data array and assign via a
 set_foo() method
foreach ($user_data as $key = $value)
{
//try
{
$pkey = strtolower($key);
//[dv] this is sort of a hack to
 automatically create a new
 property/variable
// for 'new' hashes key/values we
 may not know about.
// It's really designed to supress
 errors and they really should
 be added to this User.class.php properly.
if ( !property_exists($this, $pkey) )
{
echo creating new property
 this-$pkey with $valuebr\n;
$this-$pkey = $value; //THIS BLOWS
 UP ON THE __set()
echo this-$pkey = .$this-$pkey;
}
 
 
 Hey,
 well, $this-$pkey is wrong syntax. Try $this-pkey = $value
 

there is nothing wrong with $this-$pkey.

the question is what is __set() doing, if it's throwing an exception
for undefined properties then obviously it with 'blow up'.

I would suggest looking into using an array inside the object to
store all user data, you can still use some setter methods for user fields
that are known at compile time and for the rest you just stuff the extra/unknown
fields into the array, something like:

class Test {
private $data = array();

function loadUserData($data) {
foreach ($data as $key = $val) {
if (method_exists($this, 'set_'.$key)
$this-{'set_'.$key}($val);
else
$this-data[ $key ] = $val;
}
}
}



 -eddy
 
 
 
else
{
$class_variable = 'set_'.$pkey;
$this-$class_variable($value);
unset($user_data[$key]);
}
}
//catch (Exception $e)
{
//echo $e-getMessage().\n;
}
}

//should new fields be returned in the $user_data that are
 not
 accounted for above...
if ($_SESSION['DEVELOPMENT']  count($user_data))
{
echo !-- Unaccounted for user_data hashes. Please
 add these into
 User.class.php:\n;
var_dump($user_data);
echo --;
}

//THESE TWO LINES FATAL ERROR ON THE __get():
echo this-oraclecustomerid = .$this-oraclecustomerid;
echo this-get_oraclecustomerid() =
 .$this-get_oraclecustomerid();
 }
 ?

 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?

2009-02-03 Thread Daevid Vincent
On Tue, 2009-02-03 at 12:51 +0100, Jochem Maas wrote:

 Edmund Hertle schreef:
  2009/2/3 Daevid Vincent dae...@daevid.com
  
  Is there a way to create a new property via PHP 5.2.4?
 
  I get a hash back from an authentication server. I'm not guaranteed that
  someone in another department won't add new key/values to the returned
  hash/array. I'm trying to work around that part gracefully so that the
  code doesn't blow up on a customer in such an event. The main try/catch
  will suppress errors already, but I thought it would be nice to be able
  to handle this stuff automatically rather than constantly updating a
  User.class.php file all the time.
 
 creating new property this-oraclecustomerid with 1122
 
  but when I try to set the value with the $this-$pkey = $value;
 
  It triggers __call() which then triggers __set() which throws my
  BadProperty exception.
 
  How come $this-$pkey = $value isn't creating/setting a property?
  Or how do I do something like create_property($this, $pkey);
  so that I can then set it via $this-oraclecustomerid = 1122 or
  $this-set_oraclecustomerid(1122) ???
 
  ?php
  function load_from_user_data($user_data)
  {
 //now loop through the rest of the user_data array and assign via a
  set_foo() method
 foreach ($user_data as $key = $value)
 {
 //try
 {
 $pkey = strtolower($key);
 //[dv] this is sort of a hack to
  automatically create a new
  property/variable
 // for 'new' hashes key/values we
  may not know about.
 // It's really designed to supress
  errors and they really should
  be added to this User.class.php properly.
 if ( !property_exists($this, $pkey) )
 {
 echo creating new property
  this-$pkey with $valuebr\n;
 $this-$pkey = $value; //THIS BLOWS
  UP ON THE __set()
 echo this-$pkey = .$this-$pkey;
 }



 the question is what is __set() doing, if it's throwing an exception
 for undefined properties then obviously it with 'blow up'.



But why should __set() even be called if I'm accessing the property
directly? This seems stupid.

$this-oraclecustomerid =  1122;

should NOT be the same as

$this-set_oraclecustomerid(1122);

The second one I agree should call __set(), but the first one should NOT
be triggering __call() or __set()


  
  
  
 else
 {
 $class_variable = 'set_'.$pkey;
 $this-$class_variable($value);
 unset($user_data[$key]);
 }
 }
 //catch (Exception $e)
 {
 //echo $e-getMessage().\n;
 }
 }
 
 //should new fields be returned in the $user_data that are
  not
  accounted for above...
 if ($_SESSION['DEVELOPMENT']  count($user_data))
 {
 echo !-- Unaccounted for user_data hashes. Please
  add these into
  User.class.php:\n;
 var_dump($user_data);
 echo --;
 }
 
 //THESE TWO LINES FATAL ERROR ON THE __get():
 echo this-oraclecustomerid = .$this-oraclecustomerid;
 echo this-get_oraclecustomerid() =
  .$this-get_oraclecustomerid();
  }
  ?
 
  
 




Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?

2009-02-03 Thread Nathan Nobbe
On Tue, Feb 3, 2009 at 4:19 PM, Daevid Vincent dae...@daevid.com wrote:

 On Wed, 2009-02-04 at 08:58 +1100, Chris wrote:

   the question is what is __set() doing, if it's throwing an exception
   for undefined properties then obviously it with 'blow up'.
  
  
  
   But why should __set() even be called if I'm accessing the property
   directly? This seems stupid.
  
   $this-oraclecustomerid =  1122;
  
   should NOT be the same as
  
   $this-set_oraclecustomerid(1122);
  
   The second one I agree should call __set(), but the first one should
 NOT
   be triggering __call() or __set()
 
  Yes it should.
 
 
 http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members
 
  __set() is run when writing data to inaccessible members.
 
  if it's a protected/private variable, it'll call __set.
 
  If it's a variable that doesn't exist, it'll call __set.
 


 Let me rephrase that. I see now that it is designed that way, but I
 think the logic is erroneous.  While I'm sure this argument/discussion
 is all for naught now, I believe that a straight assignment of a value
 to a variable, SHOULD NOT do any behind the scenes magic __set(). It
 should just do it. Otherwise, what's the point of being able to set a
 property/variable both ways? One gives no benefit over the other and as
 illustrated decreases flexibility. It appears it will work if I change
 my property to public, but I don't want them exposed like that. *sigh*

 Bottom line is there should be a create_property($name, $value = null,
 $type = 'protected') function/method that I can call to do what I'm
 trying to do.

 I assume unset($this-foo); works. So therefore, I can check for
 existence of a property, and consequently remove a property, but I
 cannot create a property.


wow, obviously you can create properties at runtime.  if you want direct
access to property assignment, dont define __set() for that class.  if you
want to override this assignment, then define __set() for that class, pretty
simple..

and property creation / assignment is essentially the same thing, since all
properties must store a value.  when you 'create' a property in php w/o
explicitly giving it a value the default value is NULL.

i recommend that if you want to keep __set() defined in this class you
mentioned, and not have the melt-down b/c you have some check to see if the
property exists, you can just define another method, createOrSet($property,
$value), something to that effect, which will ignore the step about
verifying the property already exists.

-nathan


Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?

2009-02-03 Thread Chris



the question is what is __set() doing, if it's throwing an exception
for undefined properties then obviously it with 'blow up'.




But why should __set() even be called if I'm accessing the property
directly? This seems stupid.

$this-oraclecustomerid =  1122;

should NOT be the same as

$this-set_oraclecustomerid(1122);

The second one I agree should call __set(), but the first one should NOT
be triggering __call() or __set()


Yes it should.

http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members

__set() is run when writing data to inaccessible members.

if it's a protected/private variable, it'll call __set.

If it's a variable that doesn't exist, it'll call __set.

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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?

2009-02-03 Thread Daevid Vincent
On Wed, 2009-02-04 at 08:58 +1100, Chris wrote:

  the question is what is __set() doing, if it's throwing an exception
  for undefined properties then obviously it with 'blow up'.
  
  
  
  But why should __set() even be called if I'm accessing the property
  directly? This seems stupid.
  
  $this-oraclecustomerid =  1122;
  
  should NOT be the same as
  
  $this-set_oraclecustomerid(1122);
  
  The second one I agree should call __set(), but the first one should NOT
  be triggering __call() or __set()
 
 Yes it should.
 
 http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members
 
 __set() is run when writing data to inaccessible members.
 
 if it's a protected/private variable, it'll call __set.
 
 If it's a variable that doesn't exist, it'll call __set.
 


Let me rephrase that. I see now that it is designed that way, but I
think the logic is erroneous.  While I'm sure this argument/discussion
is all for naught now, I believe that a straight assignment of a value
to a variable, SHOULD NOT do any behind the scenes magic __set(). It
should just do it. Otherwise, what's the point of being able to set a
property/variable both ways? One gives no benefit over the other and as
illustrated decreases flexibility. It appears it will work if I change
my property to public, but I don't want them exposed like that. *sigh*

Bottom line is there should be a create_property($name, $value = null,
$type = 'protected') function/method that I can call to do what I'm
trying to do.

I assume unset($this-foo); works. So therefore, I can check for
existence of a property, and consequently remove a property, but I
cannot create a property.


Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?

2009-02-03 Thread Daevid Vincent
On Tue, 2009-02-03 at 08:30 +0100, Edmund Hertle wrote:

 2009/2/3 Daevid Vincent dae...@daevid.com
 
  Is there a way to create a new property via PHP 5.2.4?
 
  I get a hash back from an authentication server. I'm not guaranteed that
  someone in another department won't add new key/values to the returned
  hash/array. I'm trying to work around that part gracefully so that the
  code doesn't blow up on a customer in such an event. The main try/catch
  will suppress errors already, but I thought it would be nice to be able
  to handle this stuff automatically rather than constantly updating a
  User.class.php file all the time.
 
 creating new property this-oraclecustomerid with 1122
 
  but when I try to set the value with the $this-$pkey = $value;
 
  It triggers __call() which then triggers __set() which throws my
  BadProperty exception.
 
  How come $this-$pkey = $value isn't creating/setting a property?
  Or how do I do something like create_property($this, $pkey);
  so that I can then set it via $this-oraclecustomerid = 1122 or
  $this-set_oraclecustomerid(1122) ???
 
  ?php
  function load_from_user_data($user_data)
  {
 //now loop through the rest of the user_data array and assign via a
  set_foo() method
 foreach ($user_data as $key = $value)
 {
 //try
 {
 $pkey = strtolower($key);
 //[dv] this is sort of a hack to
  automatically create a new
  property/variable
 // for 'new' hashes key/values we
  may not know about.
 // It's really designed to supress
  errors and they really should
  be added to this User.class.php properly.
 if ( !property_exists($this, $pkey) )
 {
 echo creating new property
  this-$pkey with $valuebr\n;
 $this-$pkey = $value; //THIS BLOWS
  UP ON THE __set()
 echo this-$pkey = .$this-$pkey;
 }



 Hey,
 well, $this-$pkey is wrong syntax. Try $this-pkey = $value


No Eddie, it's one of the beautiful, simple and powerful things about
PHP. 
http://www.php.net/manual/en/language.variables.variable.php

As I loop over the hash, i am TRYING to create a new class property of
the key and assigning it the value.
$pkey is basically the hash's $key in mixed case, forced to lowercase.

You can do this for variables and for functions/methods too. This is a
'factory'. I've used it for example for parsing an XML file and
operating on the data within various 'blocks' by reading the block
name=foo value=bar and then executing $$name($value). 

Thanks for trying though. ;-)


 
 else
 {
 $class_variable = 'set_'.$pkey;
 $this-$class_variable($value);
 unset($user_data[$key]);
 }
 }
 //catch (Exception $e)
 {
 //echo $e-getMessage().\n;
 }
 }
 
 //should new fields be returned in the $user_data that are
  not
  accounted for above...
 if ($_SESSION['DEVELOPMENT']  count($user_data))
 {
 echo !-- Unaccounted for user_data hashes. Please
  add these into
  User.class.php:\n;
 var_dump($user_data);
 echo --;
 }
 
 //THESE TWO LINES FATAL ERROR ON THE __get():
 echo this-oraclecustomerid = .$this-oraclecustomerid;
 echo this-get_oraclecustomerid() =
  .$this-get_oraclecustomerid();
  }
  ?
 




Re: [PHP] How can I do the opposite of property_exists(), maybe a creat_property() in PHP5?

2009-02-02 Thread Edmund Hertle
2009/2/3 Daevid Vincent dae...@daevid.com

 Is there a way to create a new property via PHP 5.2.4?

 I get a hash back from an authentication server. I'm not guaranteed that
 someone in another department won't add new key/values to the returned
 hash/array. I'm trying to work around that part gracefully so that the
 code doesn't blow up on a customer in such an event. The main try/catch
 will suppress errors already, but I thought it would be nice to be able
 to handle this stuff automatically rather than constantly updating a
 User.class.php file all the time.

creating new property this-oraclecustomerid with 1122

 but when I try to set the value with the $this-$pkey = $value;

 It triggers __call() which then triggers __set() which throws my
 BadProperty exception.

 How come $this-$pkey = $value isn't creating/setting a property?
 Or how do I do something like create_property($this, $pkey);
 so that I can then set it via $this-oraclecustomerid = 1122 or
 $this-set_oraclecustomerid(1122) ???

 ?php
 function load_from_user_data($user_data)
 {
//now loop through the rest of the user_data array and assign via a
 set_foo() method
foreach ($user_data as $key = $value)
{
//try
{
$pkey = strtolower($key);
//[dv] this is sort of a hack to
 automatically create a new
 property/variable
// for 'new' hashes key/values we
 may not know about.
// It's really designed to supress
 errors and they really should
 be added to this User.class.php properly.
if ( !property_exists($this, $pkey) )
{
echo creating new property
 this-$pkey with $valuebr\n;
$this-$pkey = $value; //THIS BLOWS
 UP ON THE __set()
echo this-$pkey = .$this-$pkey;
}


Hey,
well, $this-$pkey is wrong syntax. Try $this-pkey = $value

-eddy




else
{
$class_variable = 'set_'.$pkey;
$this-$class_variable($value);
unset($user_data[$key]);
}
}
//catch (Exception $e)
{
//echo $e-getMessage().\n;
}
}

//should new fields be returned in the $user_data that are
 not
 accounted for above...
if ($_SESSION['DEVELOPMENT']  count($user_data))
{
echo !-- Unaccounted for user_data hashes. Please
 add these into
 User.class.php:\n;
var_dump($user_data);
echo --;
}

//THESE TWO LINES FATAL ERROR ON THE __get():
echo this-oraclecustomerid = .$this-oraclecustomerid;
echo this-get_oraclecustomerid() =
 .$this-get_oraclecustomerid();
 }
 ?



Re: [PHP] how can I make an email bounce

2008-11-24 Thread Ashley Sheridan
On Sun, 2008-11-23 at 16:01 -0800, Richard Kurth wrote:
 I need to make a bunch of emails bounce in different ways so I can check 
 to see if my script to read a mail box full of bounced emails will work 
 properly.
 Does any body know how I can do this.
 
Send some flubber as an attachment and...

Nah, you'll need to make changes to your email server (the server
receiving the emails) to recognise certain things in an email and bounce
in the ways you want.



Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how can I make an email bounce

2008-11-24 Thread [EMAIL PROTECTED]




On Nov 23, 2008, at 7:01 PM, Richard Kurth wrote:

I need to make a bunch of emails bounce in different ways so I can  
check to see if my script to read a mail box full of bounced emails  
will work properly.

Does any body know how I can do this.


If you have access to a Mac, in Apples Mail.app there is a feature  
for bouncing messages that show up like a real bounce. All you need  
are the donor e-mails to bounce from.


Just keep in mind that when you bounce a message in mail.app it  
removes the e-mail... So I wouldn't go bouncing lvoe letters from  
your girl! ;)


If you don't have such access, let me know, and I can probably help  
out with it.




--
Jason Pruim
[EMAIL PROTECTED]
616.399.2355



Re: [PHP] how can I make an email bounce

2008-11-24 Thread Richard Heyes
Hi,

 I need to make a bunch of emails bounce in different ways

Carve them into some rubber and throw them at the flloor at different
angles... :-)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 15th)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how can I make an email bounce

2008-11-24 Thread Ashley Sheridan
On Mon, 2008-11-24 at 12:53 +, Richard Heyes wrote:
 Hi,
 
  I need to make a bunch of emails bounce in different ways
 
 Carve them into some rubber and throw them at the flloor at different
 angles... :-)
 
 -- 
 Richard Heyes
 
 HTML5 Graphing for FF, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated November 15th)
 
exactly... flubbber!


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how can I make an email bounce

2008-11-24 Thread Michael Kubler
If you have a previous bounce message then something like Mail Redirect 
https://addons.mozilla.org/en-US/thunderbird/addon/550 extension in 
thunderbird might work. You simply bounce the email to yourself, or from 
one account to another.

I've used it quite often to test procmail rules, and the like.

Although, as I use gmail for my email I don't have to worry about my 
inbox being full.
Also, if you can give us more details about the actual email server then 
maybe there could be a way to induce the required bounce messages, 
somewhat like the eicar http://www.eicar.org/anti_virus_test_file.htm 
file is a semi-standardised anti-virus test. Then again, I run exim4, 
and haven't bothered looking at trying to force certain bounce messages 
without reconfiguring the server.


Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



[EMAIL PROTECTED] wrote:

On Nov 23, 2008, at 7:01 PM, Richard Kurth wrote:

I need to make a bunch of emails bounce in different ways so I can 
check to see if my script to read a mail box full of bounced emails 
will work properly.

Does any body know how I can do this.
If you have access to a Mac, in Apples Mail.app there is a feature for 
bouncing messages that show up like a real bounce. All you need are 
the donor e-mails to bounce from.


Just keep in mind that when you bounce a message in mail.app it 
removes the e-mail... So I wouldn't go bouncing lvoe letters from your 
girl! ;)


If you don't have such access, let me know, and I can probably help 
out with it.


Re: [PHP] how can I make an email bounce

2008-11-23 Thread TG
I guess you'd need to make the delivery fail.  The easiest way to do this is 
probably fill up the email box.  If you have control over the mail server, 
you could set the quota for that email box to zero.

Most other failures are going to be the result of problems that may or may 
not be easy to replicate even if you control the server.  Someone more 
intimately familiar with email servers might be able to give you some 
ideas, though.  I admit ignorance on most of that.

-TG

- Original Message -
From: Richard Kurth [EMAIL PROTECTED]
To: PHP General List php-general@lists.php.net
Date: Sun, 23 Nov 2008 16:01:24 -0800
Subject: [PHP] how can I make an email bounce

 I need to make a bunch of emails bounce in different ways so I can check 
 to see if my script to read a mail box full of bounced emails will work 
 properly.
 Does any body know how I can do this.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how can i lookup the index in a string where a regexp matches?

2008-11-18 Thread Rene Veerman

Rene Veerman wrote:
hi, i need to search with regexps in strings, and want to know the 
index (of the source string) at which the regexp matched. and the 
length of the matched string, so with substitutions like \d+..


i'm kinda in a hurry on this one, would appreciate your immediate 
answer very much..



:D i shouldnt scan texts to fast anymore.. esp when i'm in a hurry

http://nl.php.net/manual/en/function.preg-match.php

|?php
$subject = abcdef;
$pattern = '/^def/';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
? |

will produce

Array
(
   [0] = Array
   (
   [0] = def
   [1] = 0
   )

)







--
--
Rene Veerman, creator of web2.5 CMS http://mediabeez.ws/ 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] how can i lookup the index in a string where a regexp matches?

2008-11-18 Thread Boyd, Todd M.
 -Original Message-
 From: Rene Veerman [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 18, 2008 8:47 AM
 To: php php
 Subject: [PHP] how can i lookup the index in a string where a regexp
 matches?
 
 hi, i need to search with regexps in strings, and want to know the
 index
 (of the source string) at which the regexp matched. and the length of
 the matched string, so with substitutions like \d+..
 
 i'm kinda in a hurry on this one, would appreciate your immediate
 answer
 very much..

From http://www.php.net/preg_match :

flags

flags can be the following flag:

PREG_OFFSET_CAPTURE
If this flag is passed, for every occurring match the appendant
string offset will also be returned. Note that this changes the return
value in an array where every element is an array consisting of the
matched string at index 0 and its string offset into subject at index 1.


HTH,


// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] how can i lookup the index in a string where a regexp matches?

2008-11-18 Thread Boyd, Todd M.
 -Original Message-
 From: Rene Veerman [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 18, 2008 8:50 AM
 To: php php
 Subject: Re: [PHP] how can i lookup the index in a string where a
 regexp matches?
 
 Rene Veerman wrote:
  hi, i need to search with regexps in strings, and want to know the
  index (of the source string) at which the regexp matched. and the
  length of the matched string, so with substitutions like \d+..
 
  i'm kinda in a hurry on this one, would appreciate your immediate
  answer very much..
 
 :D i shouldnt scan texts to fast anymore.. esp when i'm in a hurry
 
 http://nl.php.net/manual/en/function.preg-match.php
 
 |?php
 $subject = abcdef;
 $pattern = '/^def/';
 preg_match($pattern, substr($subject,3), $matches,
 PREG_OFFSET_CAPTURE);
 print_r($matches);
 ? |
 
 will produce
 
 Array
 (
 [0] = Array
 (
 [0] = def
 [1] = 0
 )
 
 )

Are you sure about the ^? I would think '/^def/' would look for def at
the beginning of the line... anyway, glad to see you found out about the
PREG_OFFSET_CAPTURE flag.


// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Chris
Mathijs van Veluw wrote:
 Hello there,
 
 I have an shutdown function to catch fatal-errors etc..
 Now when there is an exit() somewhere i get an empty message from
 get_last_error().
 I want to know the location of this exit() or die().
 
 Is there a way to get the file and line-number from where the exit/die
 originated?

debug_backtrace ?

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from withinregister_shutdown_function()?

2008-07-16 Thread Mathijs van Veluw

Chris wrote:

Mathijs van Veluw wrote:

Hello there,

I have an shutdown function to catch fatal-errors etc..
Now when there is an exit() somewhere i get an empty message from
get_last_error().
I want to know the location of this exit() or die().

Is there a way to get the file and line-number from where the exit/die
originated?


debug_backtrace ?



This won't work from within the register_shutdown_function() function.
This because the scope is cleared, and the debug_backtrace starts from within 
the register_shutdown_function() function.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Thijs Lensselink

Quoting Mathijs van Veluw [EMAIL PROTECTED]:


Hello there,

I have an shutdown function to catch fatal-errors etc..
Now when there is an exit() somewhere i get an empty message from
get_last_error().
I want to know the location of this exit() or die().

Is there a way to get the file and line-number from where the exit/die
originated?

Thx in advance.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


I don't think this is possible in PHP. When exit(0); is called. PHP  
execution stops. In the manual there is a small comment about exit  
inside a register_shutdown_function


[snip]
Multiple calls to register_shutdown_function() can be made, and each  
will be called in the same order as they were registered. If you call  
exit() within one registered shutdown function, processing will stop  
completely and no other registered shutdown functions will be called.

[/snip]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread tedd

At 9:23 AM +0200 7/16/08, Mathijs van Veluw wrote:

Hello there,

I have an shutdown function to catch fatal-errors etc..
Now when there is an exit() somewhere i get an empty message from 
get_last_error().

I want to know the location of this exit() or die().

Is there a way to get the file and line-number from where the 
exit/die originated?


Thx in advance.


Mathijs:

For MySQL failures I use:

$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));


function report($query, $line, $file)
{
	echo($query . 'br' .$line . 'br/' . $file . 'br/' . 
mysql_error());

}

Perhaps you can modify that for your use.

Cheers,

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Eric Butera
On Wed, Jul 16, 2008 at 3:23 AM, Mathijs van Veluw
[EMAIL PROTECTED] wrote:
 Hello there,

 I have an shutdown function to catch fatal-errors etc..
 Now when there is an exit() somewhere i get an empty message from
 get_last_error().
 I want to know the location of this exit() or die().

 Is there a way to get the file and line-number from where the exit/die
 originated?

 Thx in advance.

The way I handle this is by throwing exceptions in my code.  So let's
say that there is a db connection/query failure for whatever reason.
Instead of using query() or die() which is not user friendly, I throw
an exception which bubbles up.  Once it hits the top then I can catch
it, log it accordingly, and show the user a friendlier error page
saying Oops!

With an exception you get exactly what you want, a full-blown stack
trace complete with paths, line numbers etc.  You also get the ability
to be graceful about what you show to the end user.

...but I have the feeling that you're already dealing with a situation
in lots of existing code.  Perhaps you could combine some suggestions
in this thread and replace your die/exit statements with a custom
function which logs a debug_backtrace() and then really dies, but
gracefully of course.  :)

As an aside, if I were to see some jibberish about a query and line
numbers when I click a link I'd leave that site.  (And for the
archives) It is a security vuln to show full file paths to an end
user.  If someone is tampering with your system we shouldn't give them
any more information than they can already get.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Mathijs van Veluw

Eric Butera wrote:

On Wed, Jul 16, 2008 at 3:23 AM, Mathijs van Veluw
[EMAIL PROTECTED] wrote:

Hello there,

I have an shutdown function to catch fatal-errors etc..
Now when there is an exit() somewhere i get an empty message from
get_last_error().
I want to know the location of this exit() or die().

Is there a way to get the file and line-number from where the exit/die
originated?

Thx in advance.


The way I handle this is by throwing exceptions in my code.  So let's
say that there is a db connection/query failure for whatever reason.
Instead of using query() or die() which is not user friendly, I throw
an exception which bubbles up.  Once it hits the top then I can catch
it, log it accordingly, and show the user a friendlier error page
saying Oops!

With an exception you get exactly what you want, a full-blown stack
trace complete with paths, line numbers etc.  You also get the ability
to be graceful about what you show to the end user.

...but I have the feeling that you're already dealing with a situation
in lots of existing code.  Perhaps you could combine some suggestions
in this thread and replace your die/exit statements with a custom
function which logs a debug_backtrace() and then really dies, but
gracefully of course.  :)

As an aside, if I were to see some jibberish about a query and line
numbers when I click a link I'd leave that site.  (And for the
archives) It is a security vuln to show full file paths to an end
user.  If someone is tampering with your system we shouldn't give them
any more information than they can already get.


Well i don't use 'OR die()' stuff. But exceptions.

For some reason from within the register_shutdown_function() function i get an 
empty error message.
This only occurs, as far as i know, when there is an exit somewhere.

I want to trace where this comes from.

But i think that this isn't possible, as i looked on the web and there arn't 
any solutions.

Thx for the help.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Eric Butera
On Wed, Jul 16, 2008 at 9:41 AM, Mathijs van Veluw
[EMAIL PROTECTED] wrote:
 Well i don't use 'OR die()' stuff. But exceptions.

 For some reason from within the register_shutdown_function() function i get
 an empty error message.
 This only occurs, as far as i know, when there is an exit somewhere.

 I want to trace where this comes from.

 But i think that this isn't possible, as i looked on the web and there arn't
 any solutions.

 Thx for the help.

Well if this is a very specific issue that you're trying to resolve
perhaps you could try and figure out how the user triggered the error.
 You could just save the remote address and request uri, do some
access log searching and re-produce the path the user took through
your site.  This has been a helpful technique for me several times.
One of the main problems for me is that I know how to use the systems
I build, so I wouldn't click on stuff in the weird order some users
do.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Mathijs van Veluw

Eric Butera wrote:

On Wed, Jul 16, 2008 at 9:41 AM, Mathijs van Veluw
[EMAIL PROTECTED] wrote:

Well i don't use 'OR die()' stuff. But exceptions.

For some reason from within the register_shutdown_function() function i get
an empty error message.
This only occurs, as far as i know, when there is an exit somewhere.

I want to trace where this comes from.

But i think that this isn't possible, as i looked on the web and there arn't
any solutions.

Thx for the help.


Well if this is a very specific issue that you're trying to resolve
perhaps you could try and figure out how the user triggered the error.
 You could just save the remote address and request uri, do some
access log searching and re-produce the path the user took through
your site.  This has been a helpful technique for me several times.
One of the main problems for me is that I know how to use the systems
I build, so I wouldn't click on stuff in the weird order some users
do.


Well it is an cronjobed php script that executs several other scripts depending 
on the time.
Something within those cronjobs triggers the shutdown function without an exit, 
which i find very strange.
I think i have to debug it to trace the exact steps what its doing, because 
there is no exit within that script.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread tedd

At 9:15 AM -0400 7/16/08, Eric Butera wrote:

As an aside, if I were to see some jibberish about a query and line
numbers when I click a link I'd leave that site.  (And for the
archives) It is a security vuln to show full file paths to an end
user.  If someone is tampering with your system we shouldn't give them
any more information than they can already get.


It can certainly help you for debugging, but I agree, it's not for production.

tedd

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread Eric Butera
On Wed, Jul 16, 2008 at 1:53 PM, tedd [EMAIL PROTECTED] wrote:
 At 9:15 AM -0400 7/16/08, Eric Butera wrote:

 As an aside, if I were to see some jibberish about a query and line
 numbers when I click a link I'd leave that site.  (And for the
 archives) It is a security vuln to show full file paths to an end
 user.  If someone is tampering with your system we shouldn't give them
 any more information than they can already get.

 It can certainly help you for debugging, but I agree, it's not for
 production.

 tedd

I register an error handler  a shutdown function on new features so
that I can get error reports via email.  I hate trying to sift thru
logs and junk so I really need it in my face.  Of course this is a
performance hit as it actually has to send emails and parse errors,
but after I haven't got any mails in a while I turn it off.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?

2008-07-16 Thread tedd

At 2:18 PM -0400 7/16/08, Eric Butera wrote:

On Wed, Jul 16, 2008 at 1:53 PM, tedd [EMAIL PROTECTED] wrote:

 At 9:15 AM -0400 7/16/08, Eric Butera wrote:


 As an aside, if I were to see some jibberish about a query and line
 numbers when I click a link I'd leave that site.  (And for the
 archives) It is a security vuln to show full file paths to an end
 user.  If someone is tampering with your system we shouldn't give them
 any more information than they can already get.


 It can certainly help you for debugging, but I agree, it's not for
 production.

 tedd


I register an error handler  a shutdown function on new features so
that I can get error reports via email.  I hate trying to sift thru
logs and junk so I really need it in my face.  Of course this is a
performance hit as it actually has to send emails and parse errors,
but after I haven't got any mails in a while I turn it off.


I don't really know how others debug, I work alone. But, I do all my 
stuff online and use the following function:


function report($query, $line, $file)
{
	echo($query . 'br' .$line . 'br/' . $file . 'br/' . 
mysql_error());

}

That gives me immediate notice of where the error occurred and what 
the error was. When I take my code to production, I simply comment 
out the echo().


I used to use a global to do that (show/not show errors), but 
consider all my error stuff in is one file, it's easy enough to 
comment out what I don't want to show.


Cheers,

tedd


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and that way it
will get destroyed when the function is done. Otherwise the object scope is
far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. That means that from the moment you call 
the static method until the end of the script that object exists. That's 
probably fine for web-based scripts that don't run for long, but I live 
in a world where classes often get used in unexpected ways so I tend to 
write code that's efficient without relying on the environment it's 
running in to clean it up.


This was your code...

?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

This would be my implementation...

?php
class Test {
public static function doSomething() {
$o = new Test();
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

Of course this is just based on what the OP said they wanted to do. If 
there is no reason to create an instance of the object then don't do it. 
It's fairly likely that I'd actually just use a static method here, but 
it depends on what it's actually doing.


But as I said earlier, each to their own.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Stut schreef:

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and that 
way it
will get destroyed when the function is done. Otherwise the object 
scope is

far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. 


huh? the OPs getInstance() method returns a new object on each call, hardly
a singleton is it?

That means that from the moment you call
the static method until the end of the script that object exists. That's 
probably fine for web-based scripts that don't run for long, but I live 
in a world where classes often get used in unexpected ways so I tend to 
write code that's efficient without relying on the environment it's 
running in to clean it up.


are you saying that the OPs getInstance() method causes each new instance
to hang around inside memory because php doesn't know that it's no longer 
referenced,
even when it's used like so:

Test::getInstance()-doSomething();

and that your alternative does allow php to clean up the memory?



This was your code...

?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

This would be my implementation...

?php
class Test {
public static function doSomething() {
$o = new Test();
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

Of course this is just based on what the OP said they wanted to do. If 
there is no reason to create an instance of the object then don't do it. 
It's fairly likely that I'd actually just use a static method here, but 
it depends on what it's actually doing.


But as I said earlier, each to their own.

-Stut



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Jochem Maas wrote:

Stut schreef:

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and that 
way it
will get destroyed when the function is done. Otherwise the object 
scope is

far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. 


huh? the OPs getInstance() method returns a new object on each call, hardly
a singleton is it?


Quite right too. Didn't read it properly.


That means that from the moment you call
the static method until the end of the script that object exists. 
That's probably fine for web-based scripts that don't run for long, 
but I live in a world where classes often get used in unexpected ways 
so I tend to write code that's efficient without relying on the 
environment it's running in to clean it up.


are you saying that the OPs getInstance() method causes each new instance
to hang around inside memory because php doesn't know that it's no 
longer referenced,

even when it's used like so:

Test::getInstance()-doSomething();

and that your alternative does allow php to clean up the memory?


I could be wrong, I don't know the internals of PHP well enough to be 
definitive, but I'd rather err on the side of caution than write leaky code.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Stut schreef:

Jochem Maas wrote:

Stut schreef:

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and 
that way it
will get destroyed when the function is done. Otherwise the object 
scope is

far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. 


huh? the OPs getInstance() method returns a new object on each call, 
hardly

a singleton is it?


Quite right too. Didn't read it properly.


That means that from the moment you call
the static method until the end of the script that object exists. 
That's probably fine for web-based scripts that don't run for long, 
but I live in a world where classes often get used in unexpected ways 
so I tend to write code that's efficient without relying on the 
environment it's running in to clean it up.


are you saying that the OPs getInstance() method causes each new instance
to hang around inside memory because php doesn't know that it's no 
longer referenced,

even when it's used like so:

Test::getInstance()-doSomething();

and that your alternative does allow php to clean up the memory?


I could be wrong, I don't know the internals of PHP well enough to be 
definitive, but I'd rather err on the side of caution than write leaky 
code.


the way I understand garbage collection as it is right now is that pretty much
nothing is cleaned up until the end of the request but that php should be able
to see that the ref count is zero in both cases either way.

IIUC the yet to be released garbage collection improvements will potentially 
find/destroy
unused zvals sooner (as well as being better in sorting out defunct circular 
references etc)
but that the garbage collection itself uses a certain ammount of cpu cycles and 
in short
running scripts (e.g. most of what we write for the web) it's likely to be 
better to
let php just destroy memory at the end of the request.

that said your more cautious approach cannot hurt :-)

PS - my apologies if the memory related terminology I've used is somewhat bogus 
- please
put it down to my lack of proper understanding :-/



-Stut



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Anup Shukla

Nathan Nobbe wrote:

Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.



im pretty sure constructors return an object instance:
php  class Test { function __construct() {} }
php  var_dump(new Test());
object(Test)#1 (0) {
}



AFAIK, constructor simply constructs the object,
and *new* is the one that binds the reference to the variable
on the lhs.

So, constructors return nothing.


but anyway, how could you even test that __construct() returned void
and the new keyword returned a copy of the object?  new essentially
invokes __construct() and passes along its return value, near as i can tell.

Christoph,
if you dont want to write a function in the global namespace, as suggested
in the article, Eric posted, just add a simple factory method in your class,
eg.
?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

-nathan




--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Anup Shukla schreef:

Nathan Nobbe wrote:

Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.



im pretty sure constructors return an object instance:
php  class Test { function __construct() {} }
php  var_dump(new Test());
object(Test)#1 (0) {
}



AFAIK, constructor simply constructs the object,
and *new* is the one that binds the reference to the variable
on the lhs.


not exactly - 'new' asks php to initialize an object of the given class,
the 'binding' to a variable occurs because of the assignment operator. the 
__construct()
method is called automatically by php after the object structure has been 
initialized, so primarily
nothing is returned because the call to __construct() doesn't happen directly 
in userland code.

at least that's how I understand it.



So, constructors return nothing.


but anyway, how could you even test that __construct() returned void
and the new keyword returned a copy of the object?  new essentially
invokes __construct() and passes along its return value, near as i can 
tell.


Christoph,
if you dont want to write a function in the global namespace, as 
suggested
in the article, Eric posted, just add a simple factory method in your 
class,

eg.
?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

-nathan






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 5:56 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
 You posted a singleton pattern.


no, what i posted was a simple factory pattern.
if you invoke it twice there will be 2 instances of Test in memory,
eg. not singleton.
$a = Test::getInstance();
$b = Test::getInstance();


 That means that from the moment you call
 the static method until the end of the script that object exists. That's
 probably fine for web-based scripts that don't run for long, but I live
 in a world where classes often get used in unexpected ways so I tend to
 write code that's efficient without relying on the environment it's
 running in to clean it up.


i usually only need to do cleanup in cli scripts that batch large amounts of
data.  this is my practical experience anyway.


 This would be my implementation...

 ?php
 class Test {
 public static function doSomething() {
 $o = new Test();
 $o-_doSomething();
 }

 protected function _doSomething() {
 // I'm assuming this method is fairly complex, and involves
 // more than just this method, otherwise there is no point
 // in creating an instance of the class, just use a static
 // method.
 }
 }
 Test::doSomething();
 ?

 Of course this is just based on what the OP said they wanted to do. If
 there is no reason to create an instance of the object then don't do it.


well you are still creating an instance of the object.  the only difference
is
you are forcing it the ref count to 0 by assigning the instance to a local
local variable.

It's fairly likely that I'd actually just use a static method here,


both your and my code use static methods.  it sounds to me like you are
using the term 'static method' to mean a static method that has a variable
with a reference to an instance of the class that it is a member of.  which
is obviously a particular use of a static method, and therefore a bad
practice
imho.  not the technique, mind you, the label of 'static method' for the
technique.


-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you? http://stut.net/


you realize you are instantiating an class in the code you posted, right?
from you post:
$o = new Test();
if i didnt know any better, id call that an instantiation of the Test 
class ;)

the only thing is you are forcing it out of scope by using a local variable
to store the reference to the object.


Seriously? You really need to read the emails you're replying to. I gave 
an example that did what the OP asked for. Then I went on to say that I 
would probably just use a static method. I never said I wasn't creating 
an instance in the example I posted.


The forcing it out of scope was the crux of my point. However, if 
Jochem is right then it's kinda pointless with the current 
implementation of the GC, but may become relevant in the new GC.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:

 Actually no, I mean I would *just* use a static method. If there is no
 reason to instantiate an object, why would you? http://stut.net/


you realize you are instantiating an class in the code you posted, right?
from you post:
$o = new Test();
if i didnt know any better, id call that an instantiation of the Test class
;)
the only thing is you are forcing it out of scope by using a local variable
to store the reference to the object.

-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:

It's fairly likely that I'd actually just use a static method here,


both your and my code use static methods.  it sounds to me like you are
using the term 'static method' to mean a static method that has a variable
with a reference to an instance of the class that it is a member of.  which
is obviously a particular use of a static method, and therefore a bad 
practice
imho.  not the technique, mind you, the label of 'static method' for the 
technique.



Actually no, I mean I would *just* use a static method. If there is no 
reason to instantiate an object, why would you?


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut




From your previous email


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
 I never said I wasn't creating
 an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut




From your previous email


?php
class Test {
public static function doSomething() {
$o = new Test();

The above line IS creating a instance of the class Test

Now with proper garbage collection, it should be wiped out when you are done 
using the static doSomething() method.


$o-_doSomething();

You could always include this to remove the instance of class Test

unset($o);


}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED] wrote:

 Calling a static method
 does not create an instance of the class.


there you go again; calling a static method does create an instance of
the class if you call new inside of it :P

-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Jim Lucas wrote:

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow 
the rule of Ronseal.


What do you think I meant by it?

-Stut



 From your previous email


?php
class Test {
public static function doSomething() {
$o = new Test();

The above line IS creating a instance of the class Test

Now with proper garbage collection, it should be wiped out when you are 
done using the static doSomething() method.


$o-_doSomething();

You could always include this to remove the instance of class Test

unset($o);


}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?


I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.

FFS.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] wrote:


 I would *just* use a static method

 *just* *just* *just* *just* *just* *just* *just* *just* *just*

 No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)

-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Calling a static method
does not create an instance of the class.


there you go again; calling a static method does create an instance of
the class if you call new inside of it :P


FFS, are you just trolling?

Note that I actually wrote *just* a static method, and I stated quite 
clearly that it was what I would do and that the code I posted was 
providing what the OP wanted. If you can't see the separation then I'm 
done with trying to convince you.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. If 
I need to provide an example to demonstrate what I meant I will, but I 
feel I made it quite clear that my comment regarding what *I* would do 
did not in any way relate to the code example I had provided above. The 
example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static function doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.

FYI I'm not at all new to OOP, in general or in PHP, so I am well aware 
that the example I originally posted created an instance of the class.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED] wrote:

 Ok, I'm going to have to assume you really are as stupid as you seem. If
 I need to provide an example to demonstrate what I meant I will, but I
 feel I made it quite clear that my comment regarding what *I* would do
 did not in any way relate to the code example I had provided above. The
 example I provided was fulfilling the OP's requirements.

 This is what *I* would do...

 ?php
 class Test {
 public static function doSomething() {
 // I'm assuming this method is fairly complex, and involves
 // more than just this method, otherwise there is no point
 // in creating an instance of the class, just use a static
 // method.

 //  See this comment here, this was taken from the
 // non-static method in the example I posted. This is what
 // I meant when I say just use a static method.
 }
 }
 Test::doSomething();
 ?

 Look ma, no instance.


well, at least its clear now, what you meant.


 FYI I'm not at all new to OOP, in general or in PHP, so I am well aware
 that the example I originally posted created an instance of the class.


glad to hear it; no hard feelings i hope..

-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. If 
I need to provide an example to demonstrate what I meant I will, but I 
feel I made it quite clear that my comment regarding what *I* would do 
did not in any way relate to the code example I had provided above. The 
example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static function doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


Now this is clear.


But to point out in the code I quoted, you said that you were going to only use 
the static method, but you were calling the static method that created an 
instance of the Test class and then calling the non-static method from the 
instance of the Test class.


Your previous example was not showing us what you were saying.  To me it looked 
like you were confused about how you were calling/creating things.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Ok, I'm going to have to assume you really are as stupid as you seem. If
I need to provide an example to demonstrate what I meant I will, but I
feel I made it quite clear that my comment regarding what *I* would do
did not in any way relate to the code example I had provided above. The
example I provided was fulfilling the OP's requirements.

This is what *I* would do...

?php
class Test {
public static function doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


well, at least its clear now, what you meant.
 


FYI I'm not at all new to OOP, in general or in PHP, so I am well aware
that the example I originally posted created an instance of the class.


glad to hear it; no hard feelings i hope..


Indeed. Now, the place where you sleep... is it guarded?

;)

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe

 Indeed. Now, the place where you sleep... is it guarded?


well it is, but..
i probly misunderstood some implication in the directions of
my virtual fortress and therefore, probly not as well a i suspect ;)

-nathan


Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut

Jim Lucas wrote:

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. 
If I need to provide an example to demonstrate what I meant I will, 
but I feel I made it quite clear that my comment regarding what *I* 
would do did not in any way relate to the code example I had provided 
above. The example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static function doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


Now this is clear.


Glad to hear it.

But to point out in the code I quoted, you said that you were going to 
only use the static method, but you were calling the static method that 
created an instance of the Test class and then calling the non-static 
method from the instance of the Test class.


I thought the comment in that static method explained that I didn't see 
the point in creating the instance. I thought it was pretty clear, but 
clearly not.


Your previous example was not showing us what you were saying.  To me it 
looked like you were confused about how you were calling/creating things.


I was never confused! ;)

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   3   4   5   >