Re: [PHP] Function mktime() documentation question
On Sat, 2012-03-10 at 20:38 -0500, Tedd Sperling wrote: > On Mar 10, 2012, at 12:20 PM, Maciek Sokolewicz wrote: > > > function getAmountOfDaysInAMonth($month, $year) { > > $days = array(31, (($year%4==0 and ($year%100 > 0 or $year%400==0)) ? 29 > > : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); > > return $days[$month+1]; > > } > > I like that -- here's a small variation. > > function numberDaysMonth($month, $year) > { > // Leap year is definded as a year that is evenly divisible by four > // AND (year NOT evenly divisible by 100 OR year IS evenly divisible by > 400) > > $feb = ($year%4 == 0 && ($year%100 != 0 || $year%400 == 0) ) ? 29 : 28; > $days = array(0, 31, $feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); > return $days[$month]; > } > > Cheers, > > tedd > > _ > tedd.sperl...@gmail.com > http://sperling.com > > > > > > I still don't see what's wrong with date("t"); -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] questions about $_SERVER
On 11 Mar 2012, at 01:43, Tedd Sperling wrote: > On Mar 10, 2012, at 3:53 PM, tamouse mailing lists wrote: >> On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling >> wrote: >>> That's correct, but to access those variables outside of their scope (such >>> as a function) you do via a SuperGlobal, namely $GLOBAL['whatever']. >>> >>> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >>> if I'm wrong, please show me otherwise. >> >> I guess I don't know what you mean by "globals". I know what globals >> are, but not "globals". > > I don't understand your question. I know what questions are, but not your > question. :-) I think the confusion is arising because the word superglobal is used in PHP when referring to globals, because the word global has been incorrectly applied for quite some time. A global variable is a variable that is accessible in every scope, so Tedd is right… the only true globals in PHP are the superglobals. Here's an overview of the various scopes in PHP (I've probably missed some, but it's enough to make the point)… http://php.net/variables.scope $var1 = 'a'; function funcB() { // Only visible inside this function. $var2 = 'b'; } function funcB() { // This statement makes the variable from the top-level scope visible // within this function. Essentially this is the same as passing the // variable in to the function by reference. global $var1; } class classC { // Visible to methods in this class only. private $var3 = 'c'; // Visible to methods in this class and methods in derived classes. protected $var4 = 'd'; // Method visible in this class only. private methodA() { // Visible only inside this method. $var5 = 'e'; } // Method visible in this class and methods in derived classes. protected methodB() { // See funcB() global $var1; } // Method visible on any instance of this class. public methodC() { // See funcB() global $var1; } } ?> The global keyword allows you to expose a variable that has been defined at the top-level scope ($var1 in the above example) in the current scope. It does NOT create a global variable; the keyword is not an accurate reflection of what it does. My guess is that calling the top-level scope "global" made sense when functions were the only other level of scope that existed. Now that we have yet more levels of scope it can be a bit confusing. I hope this helps clear things up. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: > As such, there are no "globals" in PHP other than SuperGlobals. As I said, if > I'm wrong, please show me otherwise. A superglobal is predefined at run-time by the parser, environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, _SESSION, _COOKIE), whereas a global can be defined at any time, and is available to the current instance. 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 ...
( Been down London over night ;) ) ... and was not awake enough to change email address ... http://piwik.medw.org.uk/phpinfo.php has http://piwik.medw.org.uk/ working fine... http://piwik.rainbowdigitalmedia.org.uk/phpinfo.php is just giving seg faults on http://piwik.rainbowdigitalmedia.org.uk/ but http://rainbowdigitalmedia.org.uk/ is working perfectly. The piwik analytics is based on Zend, and I've not been able to get it working on either of the two new machines, while all of my other stuff is working fine. I started with Apache2.4.1 and PHP5.4.0 and moved back to what should be the same versions as the working machines but without success. Simon Schick wrote: Can you give us some more information? I've been working on this for some days and tried various combinations of Apache and PHP, but my starting point was Ap2.4.1 with PHP5.4.0 and I've now worked my way back through versions to what should be the same as setup as is working on piwik.medw.org.uk but I have yet to get piwik to run on either new machine! How is php called in your apache-configuration? (f)cgi, module or somehow else? You said that the configuration should be the same ... can you double-check that? Reload the services etc ... Always used module and I see no reason to change I've enabled and disable just about everything, and the installer tells me the set-up is fine. What about the logs? There must be more info in there ... THAT is what is pissing me off. ZEND does not seem to log anything usable and I have yet to establish the best way of debugging it. The rest of my stuff simply worked, gave the expected new nagging and allowed me to track and tidy them. EVERY configuration of ZEND based piwik just gives ... [notice] child pid 10345 exit signal Segmentation fault (11) With eaccelerator switched on and tracking, I can see files being cached, but have yet to work out what the next file would be, and to be honest, I'm not convinced it runs the same way every time, but that is probably just the order of parallel paths being run? -- 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
On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: > On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: >> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >> if I'm wrong, please show me otherwise. > >A superglobal is predefined at run-time by the parser, > environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, > _SESSION, _COOKIE), whereas a global can be defined at any time, and > is available to the current instance. All superglobals are globals, > but not all globals are superglobals. > > -- > > Network Infrastructure Manager > http://www.php.net/ Now I'm confused. My understanding is that all variables defined within the main script are accessible within the main script because they are all within scope by definition. Additionally, main script variables are not accessible out of scope (such as in a function) unless one uses $GLOBALS to retrieve those values. That is the limit of my understanding of $GLOBALS. 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? 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
On Mar 11, 2012, at 6:12 AM, Ashley Sheridan wrote: > > I still don't see what's wrong with > > date("t"); > > -- > Thanks, > Ash Ash: It's just too damn simple -- we need to make things complicated. :-) 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. O', the mysteries of life. 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
On 11 Mar 2012 at 18:16, Tedd Sperling wrote: > On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: > >> On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: >>> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >>> if I'm wrong, please show me otherwise. >> >>A superglobal is predefined at run-time by the parser, >> environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, >> _SESSION, _COOKIE), whereas a global can be defined at any time, and >> is available to the current instance. All superglobals are globals, >> but not all globals are superglobals. > Now I'm confused. > > My understanding is that all variables defined within the main script are > accessible within the main script because they are all within scope by > definition. > > Additionally, main script variables are not accessible out of scope (such as > in a function) unless one uses $GLOBALS to retrieve those values. In the following, $x is a global but not a super-global (AFAIK). -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Sun, Mar 11, 2012 at 7:33 PM, Tedd Sperling wrote: > On Mar 11, 2012, at 6:12 AM, Ashley Sheridan wrote: >> >> I still don't see what's wrong with >> >> date("t"); >> >> -- >> Thanks, >> Ash > > Ash: > > It's just too damn simple -- we need to make things complicated. :-) > > 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 -- 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/3/11 Lester Caine : > ( Been down London over night ;) ) ... and was not awake enough to change > email address ... > > >> http://piwik.medw.org.uk/phpinfo.php has http://piwik.medw.org.uk/ working >> fine... >> >> http://piwik.rainbowdigitalmedia.org.uk/phpinfo.php is just giving seg >> faults on http://piwik.rainbowdigitalmedia.org.uk/ but >> http://rainbowdigitalmedia.org.uk/ is working perfectly. >> >> The piwik analytics is based on Zend, and I've not been able to get it >> working on either of the two new machines, while all of my other stuff is >> working fine. I started with Apache2.4.1 and PHP5.4.0 and moved back to >> what >> should be the same versions as the working machines but without success. > > > Simon Schick wrote: >> >> Can you give us some more information? > > I've been working on this for some days and tried various combinations of > Apache and PHP, but my starting point was Ap2.4.1 with PHP5.4.0 and I've now > worked my way back through versions to what should be the same as setup as > is working on piwik.medw.org.uk but I have yet to get piwik to run on either > new machine! > >> How is php called in your apache-configuration? (f)cgi, module or somehow >> else? >> You said that the configuration should be the same ... can you >> double-check that? Reload the services etc ... > > Always used module and I see no reason to change > I've enabled and disable just about everything, and the installer tells me > the set-up is fine. > >> What about the logs? There must be more info in there ... > > THAT is what is pissing me off. ZEND does not seem to log anything usable > and I have yet to establish the best way of debugging it. The rest of my > stuff simply worked, gave the expected new nagging and allowed me to track > and tidy them. EVERY configuration of ZEND based piwik just gives ... > [notice] child pid 10345 exit signal Segmentation fault (11) > With eaccelerator switched on and tracking, I can see files being cached, > but have yet to work out what the next file would be, and to be honest, I'm > not convinced it runs the same way every time, but that is probably just the > order of parallel paths being run? > > -- > 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 > Hi, Lester You're talking about some kind of "installer" ... What exactly is it? And what exactly do you mean with "ZEND does not seem to log ..."? Apache, PHP or something that's controlling both? And the more interesting question as you're only talking about ZEND ... in which log-file have you found the notice? I guess it's the log-file of Apache ... I guess you have already tried to set Apache and PHP to the lowest possible error-level ... I searched up the inet and came across totally different solutions ... Things that I found you can try: * Replace the index.php ... Some people reported that this error was caused by an endless-loop in their php-script * Disable all php-modules that are not really needed (f.e. APC or eAccelerator) * Disable all superfluous apache-modules (you should have done that anyways, but let's try to put it to a minimum) Here's also one tutorial how to get more information out of the apache-process. Haven't tried that and can therefore just give the hint to test it once. http://stackoverflow.com/questions/7745578/notice-child-pid-3580-exit-signal-segmentation-fault-11-in-apache-error-l Hope you can get some more details ... 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 ...
On Mon, Mar 12, 2012 at 12:11 AM, Simon Schick wrote: > 2012/3/11 Lester Caine : >> ( Been down London over night ;) ) ... and was not awake enough to change >> email address ... >> >> >>> http://piwik.medw.org.uk/phpinfo.php has http://piwik.medw.org.uk/ working >>> fine... >>> >>> http://piwik.rainbowdigitalmedia.org.uk/phpinfo.php is just giving seg >>> faults on http://piwik.rainbowdigitalmedia.org.uk/ but >>> http://rainbowdigitalmedia.org.uk/ is working perfectly. >>> >>> The piwik analytics is based on Zend, and I've not been able to get it >>> working on either of the two new machines, while all of my other stuff is >>> working fine. I started with Apache2.4.1 and PHP5.4.0 and moved back to >>> what >>> should be the same versions as the working machines but without success. >> >> >> Simon Schick wrote: >>> >>> Can you give us some more information? >> >> I've been working on this for some days and tried various combinations of >> Apache and PHP, but my starting point was Ap2.4.1 with PHP5.4.0 and I've now >> worked my way back through versions to what should be the same as setup as >> is working on piwik.medw.org.uk but I have yet to get piwik to run on either >> new machine! >> >>> How is php called in your apache-configuration? (f)cgi, module or somehow >>> else? >>> You said that the configuration should be the same ... can you >>> double-check that? Reload the services etc ... >> >> Always used module and I see no reason to change >> I've enabled and disable just about everything, and the installer tells me >> the set-up is fine. >> >>> What about the logs? There must be more info in there ... >> >> THAT is what is pissing me off. ZEND does not seem to log anything usable >> and I have yet to establish the best way of debugging it. The rest of my >> stuff simply worked, gave the expected new nagging and allowed me to track >> and tidy them. EVERY configuration of ZEND based piwik just gives ... >> [notice] child pid 10345 exit signal Segmentation fault (11) >> With eaccelerator switched on and tracking, I can see files being cached, >> but have yet to work out what the next file would be, and to be honest, I'm >> not convinced it runs the same way every time, but that is probably just the >> order of parallel paths being run? >> >> -- >> 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 >> > > Hi, Lester > > You're talking about some kind of "installer" ... What exactly is it? > And what exactly do you mean with "ZEND does not seem to log ..."? > Apache, PHP or something that's controlling both? > And the more interesting question as you're only talking about ZEND > ... in which log-file have you found the notice? I guess it's the > log-file of Apache ... > I guess you have already tried to set Apache and PHP to the lowest > possible error-level ... > > I searched up the inet and came across totally different solutions ... > > Things that I found you can try: > * Replace the index.php ... Some people reported that this error was > caused by an endless-loop in their php-script I have experienced a segfault once with mod_rewrite and some endless loop in a .htaccess file. So you might want to check that too. - Matijn -- 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 ...
Matijn Woudt wrote: > Things that I found you can try: > * Replace the index.php ... Some people reported that this error was > caused by an endless-loop in their php-script I have experienced a segfault once with mod_rewrite and some endless loop in a .htaccess file. So you might want to check that too. Thanks for the hints guys, but it was the wrong direction ... piwik is an analytics package ... google analytics with steroids ;) But the code base is a bit difficult to work with when one does not use frameworks like Zend. The starting point was a segfault in PHP which needs to be fixed, but we normally manage to avoid hitting it by managing things better. The updates I'd added to the Firebird driver in Zend were missing some checks which kicked it out at which point ... NOTHING gets logged. In 12 years I've managed to avoid having to install xdebug as we have all the debug tools I need in the bitweaver framework. I've grabbed a nightly build from Derick which I needed to work on PHP5.4 and managed to dump the traces to nail down where the problem arose. I'm not sure why there is a difference between the working machines and the problem ones, but the fixes have now allowed me to get the code running, so I can then finish debugging 'in-line' which I'm used to. Next step is to move back to Apache 2.4.1 since I'm still on 2.2 but at least now I do have the tools if the problem returns then. 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? -- 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