Re: [PHP] variable-length arguments passed by reference... how?

2004-04-29 Thread Aric Caley
Marek Kilimajer wrote:

But workaround would be to call your function with array():

Thanks, I was afraid that might be the only way.  I guess its possible 
if you write an extension (like mysqli) in C?

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


[PHP] include/require inside of function

2003-07-04 Thread Aric Caley
Is there anyway to include a file inside of a function and have the included
stuff be global?  For instance if I defined a class or a function in that
include file, I want to be able to use that class outside of the function.

On the documentation for include() a poster commented that it did indeed
work like this, but my testing indicates it does not.  Everything stays
local to the function and goes away when the function ends.

Is there a way?



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



[PHP] q: extract() and get_defined_vars()

2003-06-27 Thread Aric Caley
am I assuming correctly that get_defined_vars() returns an array pretty much
like the $GLOBALS array?

If I call extract() inside of a function, then the variables it creates will
be local to that function, correct?  OK, so, is there a way to get extract()
to define those variables as global, from within a function?



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



Re: [PHP] q: extract() and get_defined_vars()

2003-06-27 Thread Aric Caley
Yes it is, you must tell the function to treat the relevant variables as
globals though, here is a way of doing it:

function Foo(){
$theArray = array('var1'='testing', 'var2'='testing2');
foreach($theArray as $varname=$value){
global $$varname;
}
extract($theArray);
}

Foo();
echo $var1BR /$var2;

The above code outputs testingBR /testing2.

Pretty sneaky.  But at this point, why bother with the extract() at all?
wouldn't this do the same thing:

function Foo(){
$theArray = array('var1'='testing', 'var2'='testing2');
foreach($theArray as $varname=$value){
$GLOBALS[$varname] = $value;
}
}

Which is what I am already doing...



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



Re: [PHP] variable scoping...

2002-04-13 Thread Aric Caley

unfortunately, this doesnt seem to work.  Rather, it works, but it doesnt
seem to work any differently than an include() (although you can't use
output buffering on it, so in that regard its different).  It seems to pass
in all the variables and classes.

My other option, which I have been avoiding, is to rename the classes... not
all that hard really; and then for variables either rename them all, or do
this:

backupallglobalvariablesandunsetthem();
setvariablesthatscriptisexpectingtosee();
include(script);
unsetallvariablesnotinbackup();
restorebackupvariables();

and then repeat this for each script I'm trying to embed...
basicaly wrap each script/application in a clean sterilized php
envirionment.

I dont know how much overhead this would add.  But it seems like the only
solution at this point.  It just occured to me that this might actualy make
things more secure in a way since the parent script will totaly control what
variables get passed in..

Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 The documentation is outdated.  That restriction has been lifted as of PHP
 version 4.0.6.

 (cc'ing phpdoc to fix)

 -Rasmus

 On Fri, 12 Apr 2002, Aric Caley wrote:

  but the virtual() documentation says you can't use it on a php script?
 
  Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   I guess the only real way is to use virtual() in this case.  That's a
bit
   clunky as well, but it isn't quite as bad as going through CGI or all
the
   way out to the port 80 level.
  
   -Rasmus
  
   On Fri, 12 Apr 2002, Aric Caley wrote:
  
Is it possible to keep the variable name-space separate between,
say,
  two
files (one included into the other) to avoid name collisions?  I'm
  trying to
get two scripts to work together on the same page.  Each script
defines
  some
classes that have the same names but work differently (ex., class
  Template).
All I need is to embed the output of one script into the other.
   
Now, I could do this by just getting the output from a URL but that
  seems
really inefficient.  Or I could run the script from the CGI version
of
  PHP
using exec() but that also seems like it could be really slow and
  clunky.
   
Is there some efficient way of doing this?
   
It would be cool if you could just put the include() inside of a
  function
and have all the classes and variable names be local inside that
  function
but that didnt seem to work...  plus the scripts explicitly access
  global
variable names.
   
   
   
--
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
 




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




[PHP] variable scoping...

2002-04-12 Thread Aric Caley

Is it possible to keep the variable name-space separate between, say, two
files (one included into the other) to avoid name collisions?  I'm trying to
get two scripts to work together on the same page.  Each script defines some
classes that have the same names but work differently (ex., class Template).
All I need is to embed the output of one script into the other.

Now, I could do this by just getting the output from a URL but that seems
really inefficient.  Or I could run the script from the CGI version of PHP
using exec() but that also seems like it could be really slow and clunky.

Is there some efficient way of doing this?

It would be cool if you could just put the include() inside of a function
and have all the classes and variable names be local inside that function
but that didnt seem to work...  plus the scripts explicitly access global
variable names.



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




[PHP] Re: variable scoping...

2002-04-12 Thread Aric Caley

Believe me, I'm not doing it on purpose.  I'm trying to get two different
script packages to play nice with each other and I want to keep the
modifications at a minumum to make it easier to update the software.
Specificaly I'm talking about a weblog package (phpslash) and forums package
(phpbb), as well as a shopping cart (phpshop), initialy... maybe others as
well.

the class name problem isnt that bad, really.  But there's global variables
as well that need to be isolated.  get/post vars, session vars, etc.

My idea is to isolate each script, pass in the global vars that it expects
to see.  The overall, parent script would keep the variables for all the
scripts under different names that dont conflict, converting them on entry
to each script.

Michael Virnstein [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 why do you have more than one class with the same name?
 would be easier using different names for different classes.
 or define a base class template
 and extend it in the files as desired, but give them unique names.
 how do you know later, which class does what in which way, when they have
 the same
 name. not very good imo.

 Aric Caley [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Is it possible to keep the variable name-space separate between, say,
two
  files (one included into the other) to avoid name collisions?  I'm
trying
 to
  get two scripts to work together on the same page.  Each script defines
 some
  classes that have the same names but work differently (ex., class
 Template).
  All I need is to embed the output of one script into the other.
 
  Now, I could do this by just getting the output from a URL but that
seems
  really inefficient.  Or I could run the script from the CGI version of
PHP
  using exec() but that also seems like it could be really slow and
clunky.
 
  Is there some efficient way of doing this?
 
  It would be cool if you could just put the include() inside of a
function
  and have all the classes and variable names be local inside that
function
  but that didnt seem to work...  plus the scripts explicitly access
global
  variable names.
 
 





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




Re: [PHP] variable scoping...

2002-04-12 Thread Aric Caley

but the virtual() documentation says you can't use it on a php script?

Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I guess the only real way is to use virtual() in this case.  That's a bit
 clunky as well, but it isn't quite as bad as going through CGI or all the
 way out to the port 80 level.

 -Rasmus

 On Fri, 12 Apr 2002, Aric Caley wrote:

  Is it possible to keep the variable name-space separate between, say,
two
  files (one included into the other) to avoid name collisions?  I'm
trying to
  get two scripts to work together on the same page.  Each script defines
some
  classes that have the same names but work differently (ex., class
Template).
  All I need is to embed the output of one script into the other.
 
  Now, I could do this by just getting the output from a URL but that
seems
  really inefficient.  Or I could run the script from the CGI version of
PHP
  using exec() but that also seems like it could be really slow and
clunky.
 
  Is there some efficient way of doing this?
 
  It would be cool if you could just put the include() inside of a
function
  and have all the classes and variable names be local inside that
function
  but that didnt seem to work...  plus the scripts explicitly access
global
  variable names.
 
 
 
  --
  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




[PHP] objects in sessions.

2002-02-27 Thread Aric Caley

If you register an object as a session variable, do you need to include the
objects class *before* start_session()?

What if I use serialize() on my object, and then register a variable with
the serialized data; then I can start_session(), do some other things, then
include the class definition, then unserialize()?



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




[PHP] Re: Seams not to be possible

2002-02-07 Thread Aric Caley

maybe you could use eval():

eval(echo \$ . $field);

- Original Message -
From: Andy [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, February 05, 2002 2:57 AM
Subject: Seams not to be possible


 This was just an error in my explenation I ment categories.

 Meanwhile I tryed var vars, but it does not work for any reason?!?!?

 My code looks like:

  $field = $categories[0].[0];
  echo $field;// returns glacier[0]
  echo 'var '.$$field.'br'; // returns bluddy nothing
  echo $categories[0]; // returns  glacier
  echo $glacier[0];// returns 110

 Does anybody know how to get the 110 out of the array?

 Thanx for any help,

 Andy
 Andy [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi there,
 
  I have a tricky array question.
 
  My app is passing via post a array variable called glacier. Now I am
  checking for the content
  of this array. Because there are more of those arrays, I am getting all
 the
  names out of a db.
 
  How is it possible to get the value and keep the name of the array
 dynamic?
 
  e.g:
  Array name passed by post is: $glacier
//
  contains e.g. $glacier[0] = testname
  Array with category names coming out of db is:   $category // contains
 e.g.
  $category[0] = glacier
 
   echo $categories[0]; // returns glacier
   echo $glacier[0];  // returns testname
 
  I tryed $categories[0][0] but it returns only the first letter of
glacier
  (g)
 
  Any ideas??
 
  Thanx, Andy
 
 
 





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




Re: [PHP] curious - any phpshop/core users?

2002-01-31 Thread Aric Caley

I've used PHPShop (the existing version, not the new core/commerce thing) to
do one site.

It's relatively easy to set up.  I've had to do some modifications to it
(namely, to make it use Payflow link, which works via HTTP requests; and
adding dropdown menus on products to select color  airtime rates -- its a
pager site).  It doesnt use templates exactly.. lots of HTML mixed with PHP.

It definately could use some work.  I havent really checked out the new
version, since the commerce module is not released yet.

I too am interested in modular systems.  I'd like to see some sort of
modular system that makes it easy to integrate together other systems which
are not modular (or are modular but dont have the modules I want).  For
instance, I am using PHPSlash, YapBB (forums) and PHPShop but there's  no
easy way to make them all work together seamlessly, each one has its own
authentication and session handling, its own database, etc.

It would be nice to have a modular API that a completely stand alone
application (like any of three I mentioned) could adhere to, that wouldnt
limit the application in any demanding way, but would allow the application
to also be a module working with any other compliant app.

For instance, forums applications -- most that I've seen are stand alone
systems.  That's fine, but what if I want a forum as a module inside of
something like PHPSlash or PHPNuke?  I could take a forums package, probably
do some pretty extensive mods to it like merging its database with my chosen
parent app, replace its authentication and user system, etc, and make it a
module.  I've seen requests for such things, how about a module for
PHPNuke?.  Then what?  What if you decide you really wanted it to work with
PHPSlash instead?  Start all over!

Everybody has their own idea of how a modular system should be structured,
generaly tailored for the application they want to use it in.  Other people
might not want to write their apps using that system because they dont want
to be tied to it, or dont want all the other baggage of the application
coming along for the ride when they just want the modularity part.

phpshop core looks interesting but its not quite what I'm thinking of, I
think.

I am currently working on such a system that would make it easy to adapt
existing applications to be modules with a minimum of modification.  Its
more of an API and a shell or glue rather than a complete application.

I dont know if I am truly getting across my idea, but I thought I'd try to
throw it out there for consideration.

Jaxon [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 thanks, but i'm looking for feedback on modular systems and shopping cart
 engines, not an IDE.
 vi works fine for me, at least for now :)

 cheers,
 jaxon

  -Original Message-
  From: Rick Emery [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, January 30, 2002 12:58 PM
  To: '[EMAIL PROTECTED]'; PHP
  Subject: RE: [PHP] curious - any phpshop/core users?
 
 
  I use PHP Coder.  It's an excellent IDE and it's free..
 
  -Original Message-
  From: Jaxon [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, January 30, 2002 11:46 AM
  To: PHP
  Subject: [PHP] curious - any phpshop/core users?
 
 
  hi,
 
  has anyone used PHPShop and Core (www.phpshop.org) ??
  i'm thinking about using it for a project and wanted to know if it's
  actually any good :)
 
  cheers,
  jaxon
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Could somebody PLEASE explain this one to me

2002-01-29 Thread Aric Caley

Why, oh WHY doesnt this work.

I get the error:

Fatal error: Call to a member function on a non-object in
c:\home\digerati\www\classtest.php3 on line 23

  If I try to make any assignments, anywhere, it dies.  What the HELL is
going on?  Obviously I must be missing something really obvious, I Just dont
know what it is.

?php
class test1
{
  function echotest()
  {
echo hi!;
  }
}

class test2
{
  var $obj;
  var $test;

  function test2()
  {
$this-$obj = new test1;
 $this-$test = duh?; //** if you take out this line, it works.
  }

  function thisisatest()
  {
$this-$obj-echotest();
  }
}

$test = new test2;

$test-thisisatest();
?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] session id's and url rewriting.

2002-01-28 Thread Aric Caley

Is there any way to access the PHP4 session URL rewriter directly?  Is there
a way to override it and use a different function (say you wanted to make a
rewriter for XML or something other than HTML)?

Could anybody point me to a function that does what the rewriter does?
Surely somebody's written such a thing I dont want to have to do it again..
:)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]