Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson

Jochem Maas wrote:
that smells like bad design (but then again you should see some of my 
code ;-)


I blame PHP not allowing func_get_args() to use references, rather than 
bad design on my part. :)



i can say with confidence 'no, your  out of luck'.


There must be some clever workaround using global scope variables and 
eval(). I just can't think of it yet.


Chris


--
Chris Jenkinson
[EMAIL PROTECTED]

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

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



Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson

Tom Rogers wrote:

Here is a cutdown version of a class loader I use, It works for php4 and
php5 and with references. It should be easy to modify.


[...]

Sorry, this does not work with references as func_get_args() copies the 
arguments passed, rather than keeping them as references. This means 
that the $variable1, $variable2, etc. variables are only references to 
the copy made with func_get_args(), rather than to the variables passed 
to the first function.


Chris

--
Chris Jenkinson
[EMAIL PROTECTED]

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

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



Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson

Eric Butera wrote:

One thing you could do is (assuming it's php4)


[...]


This is a bit of a pain though. :)


Unfortunately, changing the functions to use &$params and using 
extract() is a significant API change and as such it would be a large 
amount of effort.


Chris

--
Chris Jenkinson
[EMAIL PROTECTED]

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

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



Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Chris Jenkinson

Jochem Maas wrote:

although I wonder whether you shouldn't be re-evaluating what it is
your trying to do because I get the impression it's a whole load of work
for probably little payoff (consider that using alot of indirection in your
code will make it harder to understand/read and therefore harder to 
debug/maintain).
why not consider the possibility that all these 'by reference' args 
could be items

in a single 'by reference' array?


Yes, that would be possible, however that would involve an API change - 
as now functions would have to get their variables out of an array 
rather than just a normal variable defined in the function. At the 
moment I've just decided to add more $var_x parameters.



btw: have you met call_user_func_array() yet? (not that it
would solve the problem because it doesn't 'do' references) - also,
it's manual page offers a hack for the reference problem your working on.


Yes, I briefly considered using it. Another method I tried was building 
a list of parameters and using eval() to call the function. Since I 
can't get the variables by reference, however, I've stuck with just 
passing $var_1, $var_2, etc. to the function.


Thanks for your comments. I think the amount of effort I would spend 
learning how to use the reflection API compared to just using a defined 
number of variables labelled in sequence is not worth it. If there was 
another way, perhaps...


Chris

--
Chris Jenkinson
[EMAIL PROTECTED]

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

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



[PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Chris Jenkinson

Hi,

Currently I have a function which accepts a limited number of parameters:

call_function($function_name, &$var_1, &$var_2);

I wish to modify the function to accept an indefinite number of 
parameters, which may or may not be references.


The function call_function() then calls the function specified in 
$function_name, with the variables passed as parameters to that function.


Is this possible? Thanks for any help which can be offered.

Chris

--
Chris Jenkinson
[EMAIL PROTECTED]

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

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



[PHP] Re: preg_match question

2004-08-18 Thread Chris Jenkinson
Nicklas Bondesson wrote:
How do I find an exact match of a string with preg_match?
Example:
String1:  www.test.com/
String2: www.test.com/somepage.php?param1=true
How do you write the regexp to only return String1 and not String2 when you
match against "www.test.com" ??
You should use the ^ and $ characters which signify the start and the 
end of the string respectively.

For example:
$matched = preg_match('/^www\.test\.com$/', $string);
For more information look at the Pattern Syntax page:
 --> http://php.net/manual/en/reference.pcre.pattern.syntax.php
Chris
--
Chris Jenkinson
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Cannot Load DLLs (WinXP, Apache 2, PHP 5)

2004-08-18 Thread Chris Jenkinson
Hi,
I can't get PHP to load php_mysql.dll, required to use the mysql_*() 
functions.

I have tried a variety of values for extension_dir, including 
"C:/php/ext", "C:\php\ext", "C:\php\", "./ext/", "ext/". I have copied 
php_mysql to all these directories, but it is not loading it.

PHP is stored in C:/php, and works perfectly apart from not finding the 
MySQL dll file.

If you could advise me for how to get PHP to load this DLL, I would be 
very grateful!

Cheers,
Chris
--
Chris Jenkinson
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php