[PHP] variable statements
Question: Variable variables and variable functions work great, but how can you execute arbitrary code statements using php code stored inside variables? // Example function stuff() { echo 'Stuff'; } // end stuff() $function = 'stuff'; $function(); // works /* Given the above, I would like and had expected the below to be interpreted by the parser and executed as if it were regular static php code. */ // Should interpret: stuff(); $lucid = "stuff()"; $lucid; // doesn't work, but doesn't show an error // Should interpret: if (1) { echo $function; } $lucid = "if (1) { echo $function; }"; $lucid; // doesn't work, but doesn't show an error Thanks for any help, Henning Sittler www.inscriber.com
RE: [PHP] variable statements
Perfect. Thank you Jason. Henning Sittler www.inscriber.com -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 26, 2002 1:44 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] variable statements On Thursday 27 June 2002 01:34, Henning Sittler wrote: > Question: Variable variables and variable functions work great, but how can > you execute arbitrary code statements using php code stored inside > variables? eval() -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Speak softly and own a big, mean Doberman. -- Dave Millman */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] RegEx question
$string = 'somethingphp'; $pat = 'php$'; $hasphp = ereg($pat, $string); Henning Sittler www.inscriber.com -Original Message- From: David Busby [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 02, 2002 4:49 PM To: php-general Subject: [PHP] RegEx question List, How can I regex to compare the last three chars of a string to "php"? /B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sigh... forms
Speaking of forms, and I'm sure lots have asked this before me, but anyone know anywhere I can go to see some examples or existing code for automatically generating and and validating dynamic forms? Wait though, I'm already doing this myself. To explain further, what I really want is an abstract set of php functions to say, ok, I want another form with say 10 questions, and I want to define each question and set of possible answers (input types and ranges) manually, and have the action script automatically check that the input types and ranges for each question are valid. Henning Sittler www.inscriber.com -Original Message- From: Chris Earle [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 09, 2002 1:38 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] can I call a variable... using variables? Why not just make the form's input names "var[]" then PHP will make them into an array: for ($i = 1; $i < 100; $i++) { if ($var[$i -1] > 0) echo "Yup. ". $var[$i - 1] ." is greater than 0."; } -- 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] Getting the URL that triggered a 404.
The $_SERVER environment variables should be there, I'm using them. Henning Sittler www.inscriber.com -Original Message- From: Brian McGarvie [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 11, 2002 12:00 PM To: Robert Cummings; [EMAIL PROTECTED] Subject: RE: [PHP] Getting the URL that triggered a 404. you can get the webserver to redirect to a custom errorhandler that could be a php script to do whatever you want. > -Original Message- > From: Robert Cummings [mailto:[EMAIL PROTECTED]] > Sent: 11 July 2002 4:44 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Getting the URL that triggered a 404. > > > > When the 404 is caught and a PHP script is executed there doesn't > appear to be any information in the environment variables indicating > what URL triggered the 404. Could someone tell me how to obtain that > information? > > Cheers, > Rob. > -- > .-. > | Robert Cummings | > :-`. > | Webdeployer - Chief PHP and Java Programmer | > :--: > | Mail : mailto:[EMAIL PROTECTED] | > | Phone : (613) 731-4046 x.109 | > :--: > | Website : http://www.webmotion.com | > | Fax : (613) 260-9545 | > `--' > > -- > 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
RE: [PHP] Alley-OOP! ... or not?
Why not try it for yourself? If it seems helpful then use it, if not then don't. Henning Sittler www.inscriber.com -Original Message- From: Martin Clifford [mailto:[EMAIL PROTECTED]] Sent: Monday, July 15, 2002 11:05 AM To: [EMAIL PROTECTED] Subject: [PHP] Alley-OOP! ... or not? Hey all, I've seen quite a few programs that seem to greatly favor Object Orienting Programming (OOP) in their code. I don't mean to start a holy war or anything of the sort, but as a burgeoning PHP developer, I would like the opinions of my peers. So how about it, ladies and gents? Tell me about the Pros and Cons to OOP, and why you prefer to use it/not use it! Personally, I've always used regular functions to accomplish my repetetive tasks, and OOP seems rather daunting for me, but I'm always open to new (and hopefully, more efficient) ideas! Thanks! Martin Clifford Homepage: http://www.completesource.net Developer's Forums: http://www.completesource.net/forums/ -- 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] Check for Associative Array
What's the best way to check for an Associative Array? There is no is_assoc() or similiar function listed in the manual (I don't think anyway). I'm using mysql_fetch_array() and I want to foreach only the assoc. part of the array without using mysql_fetch_assoc(): foreach ($arr as $key=>$value) { echo "$key:$value"; } But of course it show both the indexed array and the assoc array contents. Is there an existing function to check this, or should I do one of these things inside the foreach loop: A) set $last=value and just check if $value = $lastval B) check if the $key is just a number or just a string C) $key += 1 ?? Thanks, Henning Sittler www.inscriber.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Check for Associative Array
Ya, except I want the whole array to exist (index and assoc. array), not just the assoc. array. So, for the time being, I'll just do this: foreach ($arr as $key=>$value) { if ( !is_int($key) ) { echo "$key:$value"; } } What is HTH ?? Henning Sittler www.inscriber.com Try this: while($row = mysql_fetch_assoc($result)) { // code here } This way, the resulting array will ONLY be associative. HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php https file download
Hello everyone, Apache 2.0.40 PHP 4.2.2 Linux I have a single php script for downloading requested files. It works beautifully on http over port 80. It does NOT work at all over https on port 443. I am using the exact same script (the very same file) for both http and https connections. Apache has the +StdEnvVars enabled for all files and dirs under the https site. Forms and cookies are working normally, as are redirect headers. But for some reason, the headers for file downlaods are not working at all over ssl. I am really only testing this with IE 6 right now. What am I missing? What else can I check for? d.php function d() { $fsp = '/mydir/myfile.exe'; $mimetype='application/octect-stream'; $encoding='binary'; //echo basename($fsp).filesize($fsp); return; //header('Location: https://my.site.com/'); header('Content-Type: '.$mimetype); header('Content-Length: '.filesize($fsp)); header('Content-Disposition: attachment; filename="'.basename($fsp).'"'); header('Content-Transfer-Encoding: '.$encoding); readfile($fsp); return; } // end d() d(); d.php I call this only after a user clicks a link on a second page. Uncommenting the line starting with echo out puts the expected basename and filesize. Uncommenting the line starting with header successfully redirects to the correct url. Leaving both the above lines commented, the user is prompted with a open / save dialog but the filename showing is now the script name, the filesize is missing, and clicking open or save shows a file tansfer window that does nothing. I have also tried testing this script with curl on linux. Here's the output. I noticed the Content-Length header is missing! curl output [EMAIL PROTECTED] curl https://my.site.com/d.php --head HTTP/1.1 200 OK Date: Wed, 18 Jun 2003 18:45:24 GMT Server: Apache/2.0.40 (Red Hat Linux) Accept-Ranges: bytes X-Powered-By: PHP/4.2.2 Set-Cookie: PHPSESSID=ca805f9f0318a53e72abacf6db8fa677; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Disposition: attachment; filename="myfile.exe" Content-Transfer-Encoding: binary Connection: close Content-Type: application/octect-stream curl output What's going on here? Thanks in advance for any help you can offer!! Henning Sittler www.inscriber.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php https file download
Beautiful, that worked immediately! Thanks for your very quick and super helpful reply, John. The solution is to change the session.cache_limiter to none in php.ini. Henning Sittler www.inscriber.com -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 9:39 AM To: Henning Sittler; [EMAIL PROTECTED] Subject: Re: [PHP] php https file download > Apache 2.0.40 > PHP 4.2.2 > Linux > > I have a single php script for downloading requested files. It works > beautifully on http over port 80. It does NOT work at all over https on > port 443. Read here: http://marc.theaimsgroup.com/?l=php-general&w=2&r=1&s=session.cache_limiter+ https&q=b ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Processing Form Data /w $_POST
it's in the manual, read here: <http://ca.php.net/manual/en/control-structures.foreach.php> Henning Sittler www.inscriber.com -Original Message- From: Kyle Babich [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 12:43 PM To: [EMAIL PROTECTED] Subject: [PHP] Processing Form Data /w $_POST I have a form (setup.php) that passes values to processSetup.php when they are written into setup.txt. I'm trying to instead of writing every idividual value into setup.txt from setup.php, write a loop that will take as many values as there are in the $_POST array and write them all into a single array in logical order in setup.txt. I'm new to php and can't figure out how to do this. I'm thinking of something like... for ($_POST) { fwrite($setup, /*something to add current $_POST value to the end of an array within $setup*/); } How should I go about this? Thank you, -- Kyle -- 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] Cookies- peanut butter or chocolate??
1. Set a big value in seconds for the time argument 2. Send 2 cookies OR Create one string value containing the two values you want to save, seperated by a a sepcific character of your choice and send this new value as your cookie. Remember to parse the cookie's value when you request it in your script, so that you determine the two seperatevalues actually stored there. Henning Sittler www.inscriber.com -Original Message- From: Sparky Kopetzky [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 4:10 PM To: PHP General Subject: [PHP] Cookies- peanut butter or chocolate?? Yes, this question is about PHP cookies. Two questions: 1. How do you setup a cookie that will not expire?? 2. How do you put 2 items that you want to save in the cookie and retrieve?? Examples in the PHP manual only show how to work with a single value. Thanks! Robin E. Kopetzky Black Mesa Computers/Internet Services www.blackmesa-isp.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Cannot modify header information - headers already sent
The problem does not appear to be database related, it appears to header related. You are trying to send header information after sending regular output. You can't do this: BUT you can do this: Try looking at line 29. that's the line where you are trying to output a header after outputing some text. Henning Sittler www.inscriber.com -Original Message- From: Logan McKinley [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 10:04 AM To: [EMAIL PROTECTED] Subject: [PHP] Cannot modify header information - headers already sent I am having a problem when i use an include file to include database connectivity, however if i cut and paste the code out of the include and place it directly into the .php file it works. I am not sure how to figure this problem out. <=== error: Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\PHP\includes\db_conn.inc:1) in c:\inetpub\wwwroot\PHP\login_action.php on line 29 <=== main page execute($strSQL); if(!$rs->EOF) { $_SESSION = "TRUE"; $out = "admin_menu.php"; } else $out = "login.php?err=error"; header("Location: ".$out); ?> <=== include open($strConn); ?> <=== include Thanks in advance, ~Logan -- 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