Re: [PHP] neubie seeking answers

2011-03-31 Thread Kirk Bailey

PERFECT SIMPLE SOLUTION. THANK YOU!

On 3/31/2011 12:34 PM, Stuart Dallas wrote:

On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
I need to extract the name of the subdirectory a page lives in to

use in the title for that page. This will be returned as a string to
echo to the output stream. Now how the heck do I do that?!?

$dir = basename(dirname(__FILE__));

-Stuart



--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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



[PHP] Re: If Statements Array and Notice Undefined Index

2011-03-31 Thread Al



On 3/31/2011 10:45 AM, Nicholas Cooper wrote:

Good day,

I have three arrays A, B and C. Anyone of them might not have the 'id' key
set which will give the Notice "Undefined index: id".

I just wanted to know what the correct approach to this problem would be;
without making the code overly complicated to read by introducing a number
of "if isset" statements.

if  ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {

}

I have notices switched off, but I want to know the right way to do this.
  There's probably a number of different right ways to solve this, how would
you do it?

Best Regards,

Nicholas



Check out array_intersect_assoc() or one of the similar functions.

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



Re: [PHP] Sessions - More Info

2011-03-31 Thread Boers Steven



Dear List -

Thank you for your help in the past.  This an update on my session 
problems.


Here is a simple test program.  It never increments the session counter; 
ie, does not detect that $_SESSION has been set.




"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

http://www.w3.org/1999/xhtml";>







I have no idea what is wrong.

I need to make my session variables work so that I can finish a project.

Help and advice, please.

Ethan Rosenberg

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]

I tried your code on my testing computer (PHP 5.2.14) and everything works 
fine. $_SESSION['views'] is counting up correctly. Maybe a problem with your 
configuration?


Beste regards.
Steven


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



Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg




127.0.0.1 localhost development subdomain.development

Don't worry about it being an FQDN.  Prior to checking with the
router or DNS servers, all modern systems check the hosts file.  Then
just add a reference to each in your Apache configuration file and
restart Apache.  Boom.  Done.

--

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

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

=


Dan -

I'm a newbie...

1] What should the line in the Apache configuration file be? Just to 
be sure, the file is: /etc/apache2/apache2.conf, correct?


2] Back to the original questionhow do I kill a session from the terminal?

Thanks.

Ethan



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



Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 05:37 PM 3/31/2011, Ethan Rosenberg wrote:

At 04:51 PM 3/31/2011, Daniel Brown wrote:

On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg  wrote:
>
> 
> Ash -
>
> I can be working on more than one program simultaneously and have one tab
> open w/ program A and another w/ program B.  The site in reference is
> "http://localhost";
>
> I hope this helps.

Ah, but running on the same domain, the session will be common.
Right.  Killing a session will kill it in both programs, as you
already know, but there's no native way to do one for one
[file|directory].  Your best bet, if at all possible, is to separate
by subdomains (which you can do on localhost, too, by modifying your
hosts file to alias like so:

127.0.0.1 localhost development subdomain.development

Don't worry about it being an FQDN.  Prior to checking with the
router or DNS servers, all modern systems check the hosts file.  Then
just add a reference to each in your Apache configuration file and
restart Apache.  Boom.  Done.

--

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

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

=


Dan -

Thanks.

Two questions:

1] What is the URL for the sub domain?

2] How do kill a session from the command line?

Ethan



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



[PHP] PHP 5.2.x with MySQL 5.5.x

2011-03-31 Thread Andre Matos
Hello,

We are migrating our MySQL database from 5.0.x to 5.5.x and I have noticed that 
the current PHP 4.4.x we have will not be compatible with the MySQL 5.5.x.. It 
has the Client API version for MySQL 5.0.x

Unfortunately at this point, we cannot use PHP 5.3.x because of some old 
application create on PHP 4.4.x. Therefore, I am looking to see if someone has 
tried the PHP 5.2.x with MySQL 5.5.x and hear the experiences they have.

Our servers run Linux and our development workstations are Mac OS X 10.6.7 
(Snow Leopard).

Has anyone tried to use the MySQL 5.5.x. with PHP 5.2.x, specially on Mac OS X?

Thanks,

Andre

--
Andre Matos
andrema...@mineirinho.org





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



Re: [PHP] Closing Session

2011-03-31 Thread Stuart Dallas
On Thursday, 31 March 2011 at 21:53, Ashley Sheridan wrote:
On Thu, 2011-03-31 at 16:40 -0400, Ethan Rosenberg wrote:
> 
> > At 02:12 PM 3/31/2011, Ashley Sheridan wrote:
> > > On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> > > 
> > > > At 01:30 PM 3/31/2011, Daniel Brown wrote:
> > > > > On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg 
> > >  wrote:
> > > > > > Dear List -
> > > > > > 
> > > > > > Thanks for your help.
> > > > > > 
> > > > > > How do I close a session form the terminal? I need the 
> > > ability to do this
> > > > > > for debugging. I often have more than one session open at the
> > > > > same time, so
> > > > > > creating a program with session_start() and session_unset() or
> > > > > > session_destoy() would probably not work.
> > > > > 
> > > > >  Can you rephrase the question, Ethan, or give more details? From
> > > > > the way it sounds, you're concerned that destroying a session will
> > > > > have implications for other sessions as well, which is not the case
> > > > > (unless all sessions are shared). For example, if you have Chrome,
> > > > > Firefox, and Internet Exploder all active, the sessions should be
> > > > > different, if even from the very same computer. However, multiple
> > > > > tabs in the same browser will generally be the same session (unless
> > > > > it's something like Chrome's Incognito feature).
> > > > > 
> > > > > --
> > > > > 
> > > > > Network Infrastructure Manager
> > > > > http://www.php.net/
> > > > =
> > > > Thanks.
> > > > 
> > > > > Multiple tabs in the same browser will generally be the same session.
> > > > 
> > > > That is what I have.
> > > > 
> > > > Ethan
> > > > 
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > 
> > > 
> > > If they're all in the same browser, then what distinguishes them from
> > > one another? If you could use that and add some sort of array in the
> > > session with entries bearing to what tabs you have open then you could
> > > use that to 'close' sessions. Why do you need multiple tabs open to the
> > > same site anyway, maybe if you explained what it is you're trying to
> > > achieve, we might help with a better way?
> > > 
> > > --
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > 
> > 
> > Ash -
> > 
> > I can be working on more than one program simultaneously and have one 
> > tab open w/ program A and another w/ program B. The site in 
> > reference is "http://localhost";
> > 
> > I hope this helps.
> > 
> > Ethan
> > 
> > 
> > MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)] 
> 
> 
> I had this problem quite a lot, so now I use sub-arrays for each site.
> For example:
> 
> $_SESSION['personal_website'] = session data;
> $_SESSION['friends_site'] = session data;
> $_SESSION['shop_down_the_road'] = session data;
> 
> Then you need only unset the specific array for that site, rather than
> the whole session.

Another option is to use http://php.net/session-set-cookie-params to set the 
path for which the session cookie is valid.

-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] Closing Session

2011-03-31 Thread Steve Staples
On Thu, 2011-03-31 at 16:51 -0400, Daniel Brown wrote:
> On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg  wrote:
> >
> > 
> > Ash -
> >
> > I can be working on more than one program simultaneously and have one tab
> > open w/ program A and another w/ program B.  The site in reference is
> > "http://localhost";
> >
> > I hope this helps.
> 
> Ah, but running on the same domain, the session will be common.
> Right.  Killing a session will kill it in both programs, as you
> already know, but there's no native way to do one for one
> [file|directory].  Your best bet, if at all possible, is to separate
> by subdomains (which you can do on localhost, too, by modifying your
> hosts file to alias like so:
> 
> 127.0.0.1 localhost development subdomain.development
> 
> Don't worry about it being an FQDN.  Prior to checking with the
> router or DNS servers, all modern systems check the hosts file.  Then
> just add a reference to each in your Apache configuration file and
> restart Apache.  Boom.  Done.
> 
> -- 
> 
> Network Infrastructure Manager
> http://www.php.net/
> 

Can you not "NAME" the sessions?  and kill/destory the named session?



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



Re: [PHP] Closing Session

2011-03-31 Thread Ashley Sheridan
On Thu, 2011-03-31 at 16:40 -0400, Ethan Rosenberg wrote:

> At 02:12 PM 3/31/2011, Ashley Sheridan wrote:
> >On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> >
> > > At 01:30 PM 3/31/2011, Daniel Brown wrote:
> > > >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg 
> >  wrote:
> > > > > Dear List -
> > > > >
> > > > > Thanks for your help.
> > > > >
> > > > > How do I close a session form the terminal?  I need the 
> > ability to do this
> > > > > for debugging.  I often have more than one session open at the
> > > > same time, so
> > > > > creating a program with session_start() and session_unset() or
> > > > > session_destoy() would probably not work.
> > > >
> > > > Can you rephrase the question, Ethan, or give more details?  From
> > > >the way it sounds, you're concerned that destroying a session will
> > > >have implications for other sessions as well, which is not the case
> > > >(unless all sessions are shared).  For example, if you have Chrome,
> > > >Firefox, and Internet Exploder all active, the sessions should be
> > > >different, if even from the very same computer.  However, multiple
> > > >tabs in the same browser will generally be the same session (unless
> > > >it's something like Chrome's Incognito feature).
> > > >
> > > >--
> > > >
> > > >Network Infrastructure Manager
> > > >http://www.php.net/
> > > =
> > > Thanks.
> > >
> > > >Multiple tabs in the same browser will generally be the same session.
> > >
> > > That is what I have.
> > >
> > > Ethan
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >If they're all in the same browser, then what distinguishes them from
> >one another? If you could use that and add some sort of array in the
> >session with entries bearing to what tabs you have open then you could
> >use that to 'close' sessions. Why do you need multiple tabs open to the
> >same site anyway, maybe if you explained what it is you're trying to
> >achieve, we might help with a better way?
> >
> >--
> >Thanks,
> >Ash
> >http://www.ashleysheridan.co.uk
> 
> 
> Ash -
> 
> I can be working on more than one program simultaneously and have one 
> tab open w/ program A and another w/ program B.  The site in 
> reference is "http://localhost";
> 
> I hope this helps.
> 
> Ethan
> 
> 
> MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 
> 
> 
> 


I had this problem quite a lot, so now I use sub-arrays for each site.
For example:

$_SESSION['personal_website'] = session data;
$_SESSION['friends_site'] = session data;
$_SESSION['shop_down_the_road'] = session data;

Then you need only unset the specific array for that site, rather than
the whole session.

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




Re: [PHP] Closing Session

2011-03-31 Thread Daniel Brown
On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg  wrote:
>
> 
> Ash -
>
> I can be working on more than one program simultaneously and have one tab
> open w/ program A and another w/ program B.  The site in reference is
> "http://localhost";
>
> I hope this helps.

Ah, but running on the same domain, the session will be common.
Right.  Killing a session will kill it in both programs, as you
already know, but there's no native way to do one for one
[file|directory].  Your best bet, if at all possible, is to separate
by subdomains (which you can do on localhost, too, by modifying your
hosts file to alias like so:

127.0.0.1 localhost development subdomain.development

Don't worry about it being an FQDN.  Prior to checking with the
router or DNS servers, all modern systems check the hosts file.  Then
just add a reference to each in your Apache configuration file and
restart Apache.  Boom.  Done.

-- 

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] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 02:12 PM 3/31/2011, Ashley Sheridan wrote:

On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:

> At 01:30 PM 3/31/2011, Daniel Brown wrote:
> >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg 
 wrote:

> > > Dear List -
> > >
> > > Thanks for your help.
> > >
> > > How do I close a session form the terminal?  I need the 
ability to do this

> > > for debugging.  I often have more than one session open at the
> > same time, so
> > > creating a program with session_start() and session_unset() or
> > > session_destoy() would probably not work.
> >
> > Can you rephrase the question, Ethan, or give more details?  From
> >the way it sounds, you're concerned that destroying a session will
> >have implications for other sessions as well, which is not the case
> >(unless all sessions are shared).  For example, if you have Chrome,
> >Firefox, and Internet Exploder all active, the sessions should be
> >different, if even from the very same computer.  However, multiple
> >tabs in the same browser will generally be the same session (unless
> >it's something like Chrome's Incognito feature).
> >
> >--
> >
> >Network Infrastructure Manager
> >http://www.php.net/
> =
> Thanks.
>
> >Multiple tabs in the same browser will generally be the same session.
>
> That is what I have.
>
> Ethan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


If they're all in the same browser, then what distinguishes them from
one another? If you could use that and add some sort of array in the
session with entries bearing to what tabs you have open then you could
use that to 'close' sessions. Why do you need multiple tabs open to the
same site anyway, maybe if you explained what it is you're trying to
achieve, we might help with a better way?

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



Ash -

I can be working on more than one program simultaneously and have one 
tab open w/ program A and another w/ program B.  The site in 
reference is "http://localhost";


I hope this helps.

Ethan


MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Re: session variable problem

2011-03-31 Thread markb

On 3/25/2011 12:09 PM, markb wrote:

Very rusty with PHP.
We moved our web site to a new hosting service (godaddy). PHP changed
from 4x to 5.2.17.
I can no longer change $_SESSION variables after the first use.
First call to form - start session create variables
Second call - can read variables, change existing ones (but they do not
persist to next call) - cannot create new variable without an error

Using $_SESSION['varname'] always
session.auto_start off
register_globals off
session.use_only_cookies off

I assume this is setting difference but I can't seem to find it.





OK. found the issue.

ini_set('session.cookie_secure',true);

Causes the issue IF I don't use https.  Make sense I suppose.


--
Mark B

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



Re: [PHP] Closing Session

2011-03-31 Thread Daniel Brown
On Thu, Mar 31, 2011 at 13:54, Ethan Rosenberg  wrote:
>
> That is what I have.

So now the guessing game begins, I suppose, right?

What happened to rephrasing the original question, Ethan?  ;-P

(And why did you send me a link to your copy of WinZip?)

-- 

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] is there a static constructor?

2011-03-31 Thread Admin
Why not just create a no named function in the top of the class. This this way 
it loads on include.

Richard Buskirk
Sent from my iPhone

On Mar 31, 2011, at 12:56 AM, "D. Dante Lorenso"  wrote:

> All,
> 
> I want to build a config file class that gets called statically.  Is there 
> such a thing as a static constructor?  Example:
> 
> class Daz_Config {
>  public static function load() {
>...
>  }
>  public static function get($key) {
>self :: load();
>...
>  }
> }
> 
> Daz_Config :: get('myvalue');
> 
> I want to call the load function when the class is used for the first time.  
> If no code ever calls "Daz_Config :: get(...)" then I never want to invoke 
> load() but if it does get called, I only want to call load() once before the 
> class is used further.
> 
> Anyone know how to do this with calling load() at the top of all the other 
> functions and writing a load() function that exits early if already loaded?
> 
> -- Dante
> 
> -- 
> 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] Closing Session

2011-03-31 Thread Ashley Sheridan
On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:

> At 01:30 PM 3/31/2011, Daniel Brown wrote:
> >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg  wrote:
> > > Dear List -
> > >
> > > Thanks for your help.
> > >
> > > How do I close a session form the terminal?  I need the ability to do this
> > > for debugging.  I often have more than one session open at the 
> > same time, so
> > > creating a program with session_start() and session_unset() or
> > > session_destoy() would probably not work.
> >
> > Can you rephrase the question, Ethan, or give more details?  From
> >the way it sounds, you're concerned that destroying a session will
> >have implications for other sessions as well, which is not the case
> >(unless all sessions are shared).  For example, if you have Chrome,
> >Firefox, and Internet Exploder all active, the sessions should be
> >different, if even from the very same computer.  However, multiple
> >tabs in the same browser will generally be the same session (unless
> >it's something like Chrome's Incognito feature).
> >
> >--
> >
> >Network Infrastructure Manager
> >http://www.php.net/
> =
> Thanks.
> 
> >Multiple tabs in the same browser will generally be the same session.
> 
> That is what I have.
> 
> Ethan
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


If they're all in the same browser, then what distinguishes them from
one another? If you could use that and add some sort of array in the
session with entries bearing to what tabs you have open then you could
use that to 'close' sessions. Why do you need multiple tabs open to the
same site anyway, maybe if you explained what it is you're trying to
achieve, we might help with a better way?

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




Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 01:30 PM 3/31/2011, Daniel Brown wrote:

On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg  wrote:
> Dear List -
>
> Thanks for your help.
>
> How do I close a session form the terminal?  I need the ability to do this
> for debugging.  I often have more than one session open at the 
same time, so

> creating a program with session_start() and session_unset() or
> session_destoy() would probably not work.

Can you rephrase the question, Ethan, or give more details?  From
the way it sounds, you're concerned that destroying a session will
have implications for other sessions as well, which is not the case
(unless all sessions are shared).  For example, if you have Chrome,
Firefox, and Internet Exploder all active, the sessions should be
different, if even from the very same computer.  However, multiple
tabs in the same browser will generally be the same session (unless
it's something like Chrome's Incognito feature).

--

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

=
Thanks.


Multiple tabs in the same browser will generally be the same session.


That is what I have.

Ethan

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

Re: [PHP] Closing Session

2011-03-31 Thread Daniel Brown
On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg  wrote:
> Dear List -
>
> Thanks for your help.
>
> How do I close a session form the terminal?  I need the ability to do this
> for debugging.  I often have more than one session open at the same time, so
> creating a program with session_start() and session_unset() or
> session_destoy() would probably not work.

Can you rephrase the question, Ethan, or give more details?  From
the way it sounds, you're concerned that destroying a session will
have implications for other sessions as well, which is not the case
(unless all sessions are shared).  For example, if you have Chrome,
Firefox, and Internet Exploder all active, the sessions should be
different, if even from the very same computer.  However, multiple
tabs in the same browser will generally be the same session (unless
it's something like Chrome's Incognito feature).

-- 

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] Closing Session

2011-03-31 Thread Jay Blanchard
[snip]How do I close a session form the terminal?[/snip]

http://php.net/manual/en/function.session-destroy.php
 

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



[PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

Dear List -

Thanks for your help.

How do I close a session form the terminal?  I need the ability to do 
this for debugging.  I often have more than one session open at the 
same time, so creating a program with session_start() and 
session_unset() or session_destoy() would probably not work.


Ethan 




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



Re: [PHP] neubie seeking answers

2011-03-31 Thread Steve Staples
On Thu, 2011-03-31 at 17:34 +0100, Stuart Dallas wrote:
> On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
> I need to extract the name of the subdirectory a page lives in to 
> > use in the title for that page. This will be returned as a string to 
> > echo to the output stream. Now how the heck do I do that?!?
> 
> $dir = basename(dirname(__FILE__));
> 
> -Stuart
> 
> -- 
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/

That is what I was thinking... but for some reason, I couldn't remember
it... so I did that whole explode() thing... oh well! Kirk, use that :)


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



Re: [PHP] neubie seeking answers

2011-03-31 Thread Steve Staples
On Thu, 2011-03-31 at 12:24 -0400, Kirk Bailey wrote:
> I need to extract the name of the subdirectory a page lives in to 
> use in the title for that page. This will be returned as a string to 
> echo to the output stream. Now how the heck do I do that?!?
> 
> -- 
> end
> 
> Very Truly yours,
>   - Kirk Bailey,
> Largo Florida
> 
> kniht
>+-+
>| BOX |
>+-+
> think
> 
> 

I am SURE that there is a better reply already... but quick and dirty...




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



Re: [PHP] neubie seeking answers

2011-03-31 Thread Stuart Dallas
On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
I need to extract the name of the subdirectory a page lives in to 
> use in the title for that page. This will be returned as a string to 
> echo to the output stream. Now how the heck do I do that?!?

$dir = basename(dirname(__FILE__));

-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] neubie seeking answers

2011-03-31 Thread Richard Quadling
On 31 March 2011 17:24, Kirk Bailey  wrote:
> I need to extract the name of the subdirectory a page lives in to use in the
> title for that page. This will be returned as a string to echo to the output
> stream. Now how the heck do I do that?!?

__DIR__ is the name of the directory that the __FILE__ resides in.

basename(__DIR__) will give you the directory at the end of the path
that this __FILE__ is in.

So, for ...

C:\PHP\Scripts\script.php



will show

C:\PHP\Scripts\script.php
C:\PHP\Scripts
Scripts




-- 
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



[PHP] neubie seeking answers

2011-03-31 Thread Kirk Bailey
I need to extract the name of the subdirectory a page lives in to 
use in the title for that page. This will be returned as a string to 
echo to the output stream. Now how the heck do I do that?!?


--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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



Re: [PHP] If Statements Array and Notice Undefined Index

2011-03-31 Thread Nicholas Cooper
On 31 March 2011 15:53, Stuart Dallas  wrote:

> On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
> Good day,
> >
> > I have three arrays A, B and C. Anyone of them might not have the 'id'
> key
> > set which will give the Notice "Undefined index: id".
> >
> > I just wanted to know what the correct approach to this problem would be;
> > without making the code overly complicated to read by introducing a
> number
> > of "if isset" statements.
> >
> > if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
> >
> > }
> >
> > I have notices switched off, but I want to know the right way to do this.
> >  There's probably a number of different right ways to solve this, how
> would
> > you do it?
>
> This is how I handle this...
>
> // Define this function somewhere global
> function ifsetor($array, $key, $default = null)
> {
> return (isset($array[$key]) ? $array[$key] : $default);
> }
>
> if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC,
> 'id') == ifsetor($arrayB, 'id'))...
>
> If you need to avoid a match if neither $arrayA nor $arrayB have an id you
> simply pass a different default for each one.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
>
> http://3ft9.com/
>
>
>
>
Thank you, that is quiet an elegant solution.

Very little additional code excluding the function and it could also easily
be extended for multi dimensional arrays by changing $key to an array and
looping through each index in turn.

Best Regards

Nicholas


[PHP] Re: session_start() may take 5 seconds :(

2011-03-31 Thread Tolas Anon
On Thu, Mar 31, 2011 at 4:53 PM, Tolas Anon  wrote:
> On Thu, Mar 31, 2011 at 7:58 AM, Tolas Anon  wrote:
>> My web-app sometimes takes just over 5 seconds to execute a single
>> start_session() statement.
>> No other connections are open to the site when i hit the button that
>> makes this happen, the session is just 78kb on a local disk, and it's
>> consistent behavior.
>> So far, it only happens when i request certain page content via AJAX,
>> but I'd like to get rid of it asap.
>> Strangely, some other page content requested under the same conditions
>> via the same pipeline returns without the delay. It doesn't do
>> anything differently except the business code, and the session is
>> opened in app-wide generic code that is executed before the business
>> code is executed. The very timing with microtime() happens before the
>> business code executes.
>>
>> I've already googled, but haven't found anything useful.
>>
>> It's on a windows box (latest wampserver) and due to a ubuntu firefox
>> limitation i can't test on linux at the moment, nor run strace on it
>> :(
>>
>
> This afternoon, all my business logic had the same delay, due to
> session_start().
>
> I bypassed the ubuntu firefox problem and was able to test under
> linux; no delay.
>
> So i'll mail the wampserver admin of this problem, and continue under ubuntu.
>
http://www.wampserver.com/phorum/read.php?2,72729

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



[PHP] Re: session_start() may take 5 seconds :(

2011-03-31 Thread Tolas Anon
On Thu, Mar 31, 2011 at 7:58 AM, Tolas Anon  wrote:
> My web-app sometimes takes just over 5 seconds to execute a single
> start_session() statement.
> No other connections are open to the site when i hit the button that
> makes this happen, the session is just 78kb on a local disk, and it's
> consistent behavior.
> So far, it only happens when i request certain page content via AJAX,
> but I'd like to get rid of it asap.
> Strangely, some other page content requested under the same conditions
> via the same pipeline returns without the delay. It doesn't do
> anything differently except the business code, and the session is
> opened in app-wide generic code that is executed before the business
> code is executed. The very timing with microtime() happens before the
> business code executes.
>
> I've already googled, but haven't found anything useful.
>
> It's on a windows box (latest wampserver) and due to a ubuntu firefox
> limitation i can't test on linux at the moment, nor run strace on it
> :(
>

This afternoon, all my business logic had the same delay, due to
session_start().

I bypassed the ubuntu firefox problem and was able to test under
linux; no delay.

So i'll mail the wampserver admin of this problem, and continue under ubuntu.

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



Re: [PHP] If Statements Array and Notice Undefined Index

2011-03-31 Thread Stuart Dallas
On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
Good day,
> 
> I have three arrays A, B and C. Anyone of them might not have the 'id' key
> set which will give the Notice "Undefined index: id".
> 
> I just wanted to know what the correct approach to this problem would be;
> without making the code overly complicated to read by introducing a number
> of "if isset" statements.
> 
> if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
> 
> }
> 
> I have notices switched off, but I want to know the right way to do this.
>  There's probably a number of different right ways to solve this, how would
> you do it?

This is how I handle this...

// Define this function somewhere global
function ifsetor($array, $key, $default = null)
{
return (isset($array[$key]) ? $array[$key] : $default);
}

if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC, 'id') 
== ifsetor($arrayB, 'id'))...

If you need to avoid a match if neither $arrayA nor $arrayB have an id you 
simply pass a different default for each one.

-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



[PHP] If Statements Array and Notice Undefined Index

2011-03-31 Thread Nicholas Cooper
Good day,

I have three arrays A, B and C. Anyone of them might not have the 'id' key
set which will give the Notice "Undefined index: id".

I just wanted to know what the correct approach to this problem would be;
without making the code overly complicated to read by introducing a number
of "if isset" statements.

if  ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {

}

I have notices switched off, but I want to know the right way to do this.
 There's probably a number of different right ways to solve this, how would
you do it?

Best Regards,

Nicholas


Re: [PHP] Path question

2011-03-31 Thread tedd

At 9:18 PM -0400 3/28/11, Jack wrote:

Hello All,



Is there a smarter way to do includes by setting up a path or something
where I don't have to include /home/domain.com/includes/include_file.php

Apparently my path is as shown above,  but I would prefer to just put in
/includes/include_file.php

Thanks!

Jack



That's just a different between absolute and relative paths.

If you want to provide local files to a local script, then use 
"includes/include_file.php" -- that simply means in the same 
directory as the calling script there is a directory named "include" 
and within that directory is a file named "include_file.php".


Try it.

Sometimes people make this out to be harder than it is.

Cheers,

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

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



Re: [PHP] is there a static constructor?

2011-03-31 Thread Darren Karstens
class Daz_Config {
   private static $instance;

   private function __construct(){
  $this->load();
   }

   private function load() {
  ...
   }

   public function get($key) {
  ...
   }

   public static getInstance(){
  if (!self::$instance) self::$instance = new Daz_Config();
  return self::$instance;
   }
}

Then you can do:
Daz_Config::getInstance()->get('myvalue');