Re: [PHP] Have little enough hair as it is ...

2012-03-12 Thread Simon Schick
2012/3/12 Lester Caine :
> More irritating is
> 'Notice: Array to string conversion' which are coming up all over the place.
> I can understand what the problem is ... but trying to remove the notices is
> more challenging ...
>
> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);
> if( isset($secondsGap[1]) ) {
>        $gapName = $secondsGap[0]."to".$secondsGap[1];
> } else {
>        $gapName = $secondsGap[0];
> }
> $secondsGap[] is two numbers, which are used to create the name string, so
> what is the 'official' way of making this work without generating warnings?
>

Hi, Lester

I suggest that all done with this variable before is not of interest ...
Assuming this, I'd say the following:

> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);
Implicit initializing of an array that has the following structure:
array( array(int, int) );

> if( isset($secondsGap[1]) ) {
Trying to get the second element .. which will never happen if you
haven't added an element before the snipped you pasted here.

>$gapName = $secondsGap[0]."to".$secondsGap[1];
> } else {
>$gapName = $secondsGap[0];
> }
[some-code]

I'm quite unsure what you want to do here. If you'd update the first
line as following it would always trigger the first condition:
$secondsGap = array($gap[0] * 60, $gap[1] * 60);

Bye
Simon

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



Re: [PHP] Have little enough hair as it is ...

2012-03-12 Thread Lester Caine

Simon Schick wrote:

I suggest that all done with this variable before is not of interest ...
Assuming this, I'd say the following:


>  $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);

Implicit initializing of an array that has the following structure:
array( array(int, int) );


OK $gap comes from the loop
foreach(self::$timeGap as $gap)
self::$timeGap is a list of pairs of numbers.


>  if( isset($secondsGap[1]) ) {

Trying to get the second element .. which will never happen if you
haven't added an element before the snipped you pasted here.


>  $gapName = $secondsGap[0]."to".$secondsGap[1];
>  } else {
>  $gapName = $secondsGap[0];
>  }

[some-code]

I'm quite unsure what you want to do here. If you'd update the first
line as following it would always trigger the first condition:
$secondsGap = array($gap[0] * 60, $gap[1] * 60);
What this code is doing perfectly in PHP5.3 is generating the text string to 
display for each time period listed in the array of pairs of numbers ( some with 
a 'blank' second number and what the code returns is a string of the format 
'(number1)to(number2)' or simply '(number1)' - something fairly standard in PHP? 
But the nanny message says it need to be re-writen, the question is 'How?' :(


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

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



Re: [PHP] questions about $_SERVER

2012-03-12 Thread Daniel Brown
On Sun, Mar 11, 2012 at 14:16, Tedd Sperling  wrote:
>
> As to placing an additional requirement (i.e., being predefined) on the 
> definition as to what constitutes a SuperGlobal is outside my understanding. 
> As such, I must defer to the PHP Manual, namely:
>
> http://php.net/manual/en/language.variables.superglobals.php
>
> This document clearly states that $GLOBALS is a SuperGlobal -- what am I not 
> understanding here?

You are understanding it correctly, the only thing that's missing
is the population.  The variables are defined (set), but not all are
populated.  $GLOBALS is a superglobal, you're right; globals set from
userland scripts are not superglobals, but do wind up in the $GLOBALS
array.  Thus, all superglobals are globals, but not all globals are
superglobals.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Have little enough hair as it is ...

2012-03-12 Thread Jim Lucas

On 03/12/2012 06:38 AM, Lester Caine wrote:

Simon Schick wrote:

I suggest that all done with this variable before is not of interest ...
Assuming this, I'd say the following:




Right here you are creating two strings within an array within an array.

My guess is you will want to replace the $secondsGap[] with $secondsGap


> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);

Implicit initializing of an array that has the following structure:
array( array(int, int) );


OK $gap comes from the loop
foreach(self::$timeGap as $gap)
self::$timeGap is a list of pairs of numbers.


> if( isset($secondsGap[1]) ) {

Trying to get the second element .. which will never happen if you
haven't added an element before the snipped you pasted here.


> $gapName = $secondsGap[0]."to".$secondsGap[1];
> } else {
> $gapName = $secondsGap[0];
> }

[some-code]

I'm quite unsure what you want to do here. If you'd update the first
line as following it would always trigger the first condition:
$secondsGap = array($gap[0] * 60, $gap[1] * 60);

What this code is doing perfectly in PHP5.3 is generating the text
string to display for each time period listed in the array of pairs of
numbers ( some with a 'blank' second number and what the code returns is
a string of the format '(number1)to(number2)' or simply '(number1)' -
something fairly standard in PHP? But the nanny message says it need to
be re-writen, the question is 'How?' :(




--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Function mktime() documentation question

2012-03-12 Thread Tedd Sperling
On Mar 11, 2012, at 3:10 PM, Matijn Woudt wrote:
> On Sun, Mar 11, 2012 at 7:33 PM, Tedd Sperling  
> wrote:
>> Actually, this works for me:
>> 
>> $days_in_month = date('t', mktime(0, 0, 0, $next_month, 0, $year));
>> 
>> But again, I don't see why I have to use "next month" to find the number of 
>> days in this month.
> 
> That's because you're requesting day 0 of some month, which refers to
> the last day in the previous month.
> Try: $days_in_month = date('t', mktime(0, 0, 0, $next_month, 1, $year));
> 
> - Matijn

I got that.

Beating the same dead horse again, I think day 0 of this month should contain 
the days in this month, but I am in the minority on this.

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com

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



Re: [PHP] Function mktime() documentation question

2012-03-12 Thread Ashley Sheridan
On Mon, 2012-03-12 at 15:53 -0400, Tedd Sperling wrote:

> On Mar 11, 2012, at 3:10 PM, Matijn Woudt wrote:
> > On Sun, Mar 11, 2012 at 7:33 PM, Tedd Sperling  
> > wrote:
> >> Actually, this works for me:
> >> 
> >> $days_in_month = date('t', mktime(0, 0, 0, $next_month, 0, $year));
> >> 
> >> But again, I don't see why I have to use "next month" to find the number 
> >> of days in this month.
> > 
> > That's because you're requesting day 0 of some month, which refers to
> > the last day in the previous month.
> > Try: $days_in_month = date('t', mktime(0, 0, 0, $next_month, 1, $year));
> > 
> > - Matijn
> 
> I got that.
> 
> Beating the same dead horse again, I think day 0 of this month should contain 
> the days in this month, but I am in the minority on this.
> 
> Cheers,
> 
> tedd
> 
> _
> tedd.sperl...@gmail.com
> http://sperling.com
> 


I think a lot of the confusion is that we're so used to array indexes
beginning at 0 that we tend to assume other things should start there
too. I found this confusing when I first came across the date stuff in
PHP. Now I'm used to it, it makes sense.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] questions about $_SERVER

2012-03-12 Thread Tedd Sperling
On Mar 11, 2012, at 3:04 PM, Tim Streater wrote:
> 
> In the following, $x is a global but not a super-global (AFAIK).
> 
> 
>  
> function echox ()
> {
> 
> global $x;
> 
> echo $x;
> 
> }
> 
> $x = "Hello world\n";
> 
> echox ();
> 
> ?>
> 
> --
> Cheers  --  Tim


Tim:

I read somewhere that using:

global $x;

is not recommended. Whereas, it is recommended to use:

$x = $GLOBALS['x'];
echo $x;

In any event, what I found interesting is:

print_r($GLOBALS)

if will list all the variables (plus more) in your script. Thus, all variables 
in your main script are also included in the $GLOBALS array.

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com





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



Re: [PHP] questions about $_SERVER

2012-03-12 Thread Jim Giner
The purpose of the "global" statement within a function is to let PHP know 
that the usage of a var name INSIDE that function is not meant to create a 
NEW variable, but instead, to reference the other (global) variable being 
used (and perhaps already defined) in your main script.

Basically it works like this:

You can:
- create vars in the main script usable in that script's main body outside 
of any functions

- create vars to be used entirely and only within any functions in your 
script;

-reference vars from the main script within a specific function by 
referencing them with a "global $xxx,$yyy,$zzz" statement at the top of your 
function;

And Finally You Can:

- create $_SESSION['xxx'] var that can be seen anywhere in your 
application(s) during the life of the current session.  Close the browser or 
fail to do a "session_start()" in a script and you can't see them, but who 
would do that?

I'm sure someone will have something else to add, but I think this is all 
the knowledge one needs to accomplish most php programming. 



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



Re: [PHP] questions about $_SERVER

2012-03-12 Thread Tim Streater
On 12 Mar 2012 at 20:07, Tedd Sperling  wrote: 

> Tim:
>
> I read somewhere that using:
>
> global $x;
>
> is not recommended. Whereas, it is recommended to use:
>
> $x = $GLOBALS['x'];
> echo $x;

Tedd,

That may well be, although as I write I can't recollect having seen that 
anywhere; so I don't use that form. However I have been caught by something 
like the following:




but I haven't looked into $GLOBALS enough to know whether using them instead 
would have saved my bacon.

--
Cheers  --  Tim

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

Re: [PHP] Have little enough hair as it is ...

2012-03-12 Thread Lester Caine

Jim Lucas wrote:


Right here you are creating two strings within an array within an array.

My guess is you will want to replace the $secondsGap[] with $secondsGap


> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);


$secondsGap[] is right ... it's building an array of results ...
problem turned out to be another 'automatic merge' of the master code base with 
my local copy which had actually screwed up. At times this DVCS stuff is less 
than ideal when working on parallel ports :(


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

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