Re: [PHP] Scope of Variables and use of global and this->var

2009-07-16 Thread Eddie Drapkin
On Thu, Jul 16, 2009 at 9:53 AM, Govinda wrote: > > On Jul 15, 2009, at 3:28 PM, tedd wrote: > >> My way -- every time I open a database, I do so by including the >> configuration.php file that holds the logon/password et other data to >> connect with the database. When I'm done with what I want fr

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-16 Thread Govinda
On Jul 15, 2009, at 3:28 PM, tedd wrote: My way -- every time I open a database, I do so by including the configuration.php file that holds the logon/password et other data to connect with the database. When I'm done with what I want from the database, I close it. If one does not close i

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-15 Thread tedd
At 12:21 PM +0200 7/14/09, Anton Heuschen wrote: In my index.php page I then use $dbconnect again but do I simply use $dbconnect again ... or must I say global $dbconnect and then use it in the rest of the DB calls? or use GLOBALS .. Anton: My way -- every time I open a database, I do so

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Martin Scotta
do you need to use global? IMO you should use just 1 global variable, thats is what I call "entry point" My scripts looks like... require_once 'loader.php'; Loader::registerAutoload(); $foo = new Foo(); $foo->doStuff(); This way you can develop faster and do maintenance better avoiding problems

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Darren Karstens
> Oh and if one class uses methods in another class do I instansiate a > new object of the other class I have seen use of OtherClass::Method >  is this better method of $obj = new OtherClass()  use The :: is used to access static methods of a class. Static methods can be used withou

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Eric Butera
On Tue, Jul 14, 2009 at 6:21 AM, Anton Heuschen wrote: > This is just a general question, > > I am not 100% on when to use global $var , and $this->var  and how/what > about the GLOBAL vars > > Lets say I have one file I  call config.php here I connect to the db, to > ldap etc the con

[PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Anton Heuschen
This is just a general question, I am not 100% on when to use global $var , and $this->var and how/what about the GLOBAL vars Lets say I have one file I call config.php here I connect to the db, to ldap etc the connection "var" I can then use in a file on its own ... obviously aft

[PHP] Scope woe

2009-06-30 Thread Luke
Hello again guys, I was wondering the best way to tackle the following problem: I've got a class, containing a property which is another object. So from outside I should be able to do $firstobject->propertycontainingobject->methodinsidethatobject(); The $firstobject variable is in the global nam

Re: [PHP] Scope of the variables around PHP class

2008-09-23 Thread clive
Define a class function and pass the array via this function or pass it via the classes constructor. VamVan wrote: Hello Guys, I have a problem here. I hope you can help me resolving it. Please see the code below array.php has $array1 = ('hello'=>'heelo',) require_once('array.php'); class

Re: [PHP] Scope of the variables around PHP class

2008-09-22 Thread Chris
VamVan wrote: Hello Guys, I have a problem here. I hope you can help me resolving it. Please see the code below array.php has $array1 = ('hello'=>'heelo',) require_once('array.php'); class Classa { } How can I access the array values in my class? I want to understand the scope. You can't

[PHP] Scope of the variables around PHP class

2008-09-22 Thread VamVan
Hello Guys, I have a problem here. I hope you can help me resolving it. Please see the code below array.php has $array1 = ('hello'=>'heelo',) require_once('array.php'); class Classa { } How can I access the array values in my class? I want to understand the scope. Thanks

Re: [PHP] scope and return array( ); problems

2007-04-18 Thread Richard Lynch
On Wed, April 18, 2007 5:33 pm, Yvan Strahm wrote: > I have this function: > > function preg_array($pattern, $array, $r_array) > { > global $match; > global $r_array; Passing in $r_array *AND* declaring it global is just plain silly. Do one or the other, but not both. If the array is L

[PHP] scope and return array( ); problems

2007-04-18 Thread Yvan Strahm
Hi all, I have this code ( but you already know it ;-) : function preg_array($pattern, $array, $r_array) { global $match; global $r_array; foreach ($array as $key => $value) { if (preg_match($pattern, $value,$match)) { $r_array=array_slice($match,1); break;

[PHP] scope and return array( ); problems

2007-04-18 Thread Yvan Strahm
hi all, I have this function: function preg_array($pattern, $array, $r_array) { global $match; global $r_array; foreach ($array as $key => $value) { if (preg_match($pattern, $value,$match)) { $GA=array_slice($match,1); break; } } return array ($GA,

Re: [PHP] Scope of include

2007-01-18 Thread Stut
$foo = 'foo'; Then it's scope is the function including the file. It's important to have this clear in your head when dealing with included files, so I wrote an example that will hopefully demonstrate it for the OP... http://dev.stut.net/php/scope/ -Stut --

Re: [PHP] Scope of include

2007-01-18 Thread Robert Cummings
On Thu, 2007-01-18 at 10:29 -0500, tedd wrote: > At 9:49 PM -0800 1/17/07, jekillen wrote: > >Hello php list: > >If I include a php script inside a php function definition and then call the > >function in another script. What is the scope of variables in the included > >script? Are they local to th

Re: [PHP] Scope of include

2007-01-18 Thread tedd
At 9:49 PM -0800 1/17/07, jekillen wrote: Hello php list: If I include a php script inside a php function definition and then call the function in another script. What is the scope of variables in the included script? Are they local to the function that calls include with the file name? Thanks in

Re: [PHP] Scope of include

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 21:49:05 -0800: > Hello php list: > If I include a php script inside a php function definition and then > call the function in another script. What is the scope of variables in > the included script? Are they local to the function that calls include > with the file

Re: [PHP] Scope of include

2007-01-17 Thread Andrew Kreps
On 1/17/07, Andrew Kreps <[EMAIL PROTECTED]> wrote: On 1/17/07, jekillen <[EMAIL PROTECTED]> wrote: > Hello php list: > If I include a php script inside a php function definition and then > call the > function in another script. What is the scope of variables in the > included > script? Are they

Re: [PHP] Scope of include

2007-01-17 Thread Andrew Kreps
On 1/17/07, jekillen <[EMAIL PROTECTED]> wrote: Hello php list: If I include a php script inside a php function definition and then call the function in another script. What is the scope of variables in the included script? Are they local to the function that calls include with the file name? Tha

[PHP] Scope of include

2007-01-17 Thread jekillen
Hello php list: If I include a php script inside a php function definition and then call the function in another script. What is the scope of variables in the included script? Are they local to the function that calls include with the file name? Thanks in advance; I'm not sure where to look fo

Re: [PHP] scope of classes in PHP

2006-02-13 Thread Jochem Maas
Stuart Bailey wrote: Hi I'm developing an app to administer LDAP (phpLdapAdmin is too complex for the customer). I have created an LDAP class, in a file class_ldap.php. It include methods for connecting to the server, binding a DN (effectively login), and adding posix groups. I have an index

[PHP] scope of classes in PHP

2006-02-11 Thread Stuart Bailey
Hi I'm developing an app to administer LDAP (phpLdapAdmin is too complex for the customer). I have created an LDAP class, in a file class_ldap.php. It include methods for connecting to the server, binding a DN (effectively login), and adding posix groups. I have an index.php with include_once '

Re: [PHP] Scope issue

2004-12-20 Thread Richard Lynch
GH wrote: > Hi I am having an issue with I think it is the scope of variables: > > I have a file that I am including which has the following" > > // +-- > // | PHP Source > // +-

RE: [PHP] Scope issue

2004-12-17 Thread Mike
> In my main file, I am attempting to from with in a function > call $language['project_name'] and i am failing... can you > offer any advice? > Are there any specific reasons that you need to set the variable to global scope? It's typically recommended that unless you need to, to pass the va

[PHP] Scope issue

2004-12-17 Thread GH
Hi I am having an issue with I think it is the scope of variables: I have a file that I am including which has the following" "; global $langauge; $language['project_name'] = "P.L.I.M.S"; $language['sub_project_name'] = "DCR CC"; ?> In my main file, I am attempting to from with in a function ca

RE: [PHP] scope problem

2004-03-05 Thread Larry Brown
List Subject: Re: [PHP] scope problem Hello Larry, Friday, March 5, 2004, 4:01:39 PM, you wrote: LB> This gives values something to the tune of... LB> 200 LB> 400 LB> 700 LB> 100 Hard to say with so little code, but... Your first where loop is probably running twice, i.e. res

Re: [PHP] scope problem

2004-03-05 Thread Richard Davey
Hello Larry, Friday, March 5, 2004, 4:01:39 PM, you wrote: LB> This gives values something to the tune of... LB> 200 LB> 400 LB> 700 LB> 100 Hard to say with so little code, but... Your first where loop is probably running twice, i.e. resetting variable back to 100 after the 2nd (internal) wh

[PHP] scope problem

2004-03-05 Thread Larry Brown
Apparently I'm having some kind of meltdown here. Can anyone explain the logic behind why the following variable has the original value and how I can pull/push the value to access it at the end? while loop { $variable = 100; while loop { switch($othervar)

[PHP] Scope: global $GLOBALS[]

2004-02-16 Thread Paul Furman
I checked the manual but I still don't get it. http://us2.php.net/manual/en/language.variables.scope.php I'm setting a variable $pics with a form by post method. It's on a "screen" that is included, then it needs to be applied to another "screen" that will take it's place when it's all re-process

Re: [PHP] scope of class atts in methods

2002-06-06 Thread Erik Price
If anyone read this post, you probably already forgot about it, but I just wanted to clarify that I found the source of the problem and it was a coding mistake on my part, not a problem with PHP's array implementation. Erik On Thursday, June 6, 2002, at 03:11 PM, Erik Price wrote: > Hi

[PHP] scope of class atts in methods

2002-06-06 Thread Erik Price
Hi all, a quick question about using PHP's objects, specifically in terms of the scope of class attributes: Normally, in PHP, a variable in a function is local to that function and is NOT a reference to a similarly-named variable outside the function, right? To the best of my knowledge, ther

Re: [PHP] Scope problem in while loop

2002-03-11 Thread Randall Perry
Whoops, you're right. Classic 'C' mistake using = instead of ==. Never mind :( > On Mon, 2002-03-11 at 18:51, Randall Perry wrote: >> According to the PHP 4 docs all variables are global unless within a >> function. I've got the following test code which should output 2, but >> outputs 1. The whi

RE: [PHP] Scope problem in while loop

2002-03-11 Thread Demitrious S. Kelly
rch 11, 2002 6:52 PM To: [EMAIL PROTECTED] Subject: [PHP] Scope problem in while loop According to the PHP 4 docs all variables are global unless within a function. I've got the following test code which should output 2, but outputs 1. The while loop creates it's own class object (w

Re: [PHP] Scope problem in while loop

2002-03-11 Thread Lars Torben Wilson
On Mon, 2002-03-11 at 18:51, Randall Perry wrote: > According to the PHP 4 docs all variables are global unless within a > function. I've got the following test code which should output 2, but > outputs 1. The while loop creates it's own class object (which seems strange > since it isn't explicitl

[PHP] Scope problem in while loop

2002-03-11 Thread Randall Perry
According to the PHP 4 docs all variables are global unless within a function. I've got the following test code which should output 2, but outputs 1. The while loop creates it's own class object (which seems strange since it isn't explicitly instantiated by my code; I would think it would cause er

[PHP] scope issue?

2002-03-10 Thread Nick Wilson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I have the solution to my problem here but can't see why i need it? this snippet takes $AuthId from a form and but does not work (doesn't seem to pass it to the function) case "edit": $tips->get_author($AuthId); $content

Re: [PHP] @ Scope

2001-02-16 Thread Christian Reiniger
On Friday 16 February 2001 04:19, Maxim Maletsky wrote: > It will escape the error ... or better say you force the function to > always return true. [...] > $where = @where($user); > > this will always return true no matter what happen Bullshit (sorry. I just *had* to say this :). From the manual

RE: [PHP] @ Scope

2001-02-15 Thread Maxim Maletsky
come from, am I right ? so you use : $where = @where($user); this will always return true no matter what happen Cheers, Maxim Maletsky -Original Message- From: Karl J. Stubsjoen [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 15, 2001 1:37 AM To: PHP Mailing List Subject: [PH

Re: [PHP] @ Scope

2001-02-14 Thread Christian Reiniger
On Wednesday 14 February 2001 17:36, Karl J. Stubsjoen wrote: > When you @ "at" a command (supress error messaging) within a function, > is the scope of the @ within the function? > > Example: > > > CloseODBC(1); > > # is error message supressed here too? > > > function CloseODBC($connection_id) >

Re: [PHP] @ Scope

2001-02-14 Thread Web master
My understanding is, it simple supress the any messages generated from the result. So I guess it is local. Karl J. Stubsjoen wrote: > When you @ "at" a command (supress error messaging) within a function, is > the scope of the @ within the function? > > Example: > > > CloseODBC(1); > > # is

[PHP] @ Scope

2001-02-14 Thread Karl J. Stubsjoen
When you @ "at" a command (supress error messaging) within a function, is the scope of the @ within the function? Example: CloseODBC(1); # is error message supressed here too? function CloseODBC($connection_id) { # error messaging supressed @odbc_close($connection_id); } -- PHP G