Re: [PHP] Regexp help (simple)
Victor Spng Arthursson wrote: Have been playing around a bit with this code, but I can't get it to work with international characters For example, if I feed my function: function split_bokid($bokid) { if (preg_match('/^([a-z]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/ i',$bokid,$m='')) { return $m; } else { return false; } } returns, with the following code: $test = split_bokid(123); I assume you mean: $test = split_bokid(12345); echo $test[1]; echo $test[2]; the values: 12345 So, is there any way I can set the encoding on the incoming values, which will come from url's and databases, so that they don't fuck up? I don't know. It works fine on my computer. The letters display correctly on the command line and even in Mozilla. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this possible ?
An object-oriented way of doing it: keep the extra result in a member variable and get it separately. You might not find this necessary, but it gets more useful in more complex cases. class MyClass { var $num; Function MyFunc(){ if(isset($_POST['var'])){ $sql = mysql_query(select * from table_name where field=\$_POST[var]\ ); $this-num = mysql_num_rows($sql); $returnsomething =blah blah; } return $returnsomething; } function getCount() { return $this-num; } } Dave Carrera wrote: Hi List, I have a function that makes a call to mysql based on certain vars. ---example Function MyFunc(){ if(isset($_POST[var])){ $sql = mysql_query(select * from table_name where field=\$_POST[var]\ ); $returnsomething =blah blah; } return $returnsomething; } And that all works fine no probs here but. I want to use a result somewhere in my script that is not returned by return. Let me show you... ---example Function MyFunc(){ if(isset($_POST[var])){ $sql = mysql_query(select * from table_name where field=\$_POST[var]\ ); $num = mysql_num_rows($sql); // I want to use this result outside this function. $returnsomething =blah blah; } return $returnsomething; } So $num contains a number that I want to use outside the function which is not covered by return. I know return stops a script and returns what I want it to return but how do I send out of the function the var I want. I have tried $GLOBAL[var]=$num; but that dont work, but I thought I would'nt anyway just tried it and yes I know I have to declare it inside my new function using global $var; to use it. So I ask is this achiveable or how can I do this. Thank you in advance Dave C --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Error - This is WEIRD!
Donald Tyler wrote: Yes your right, thats exactly the problem. I didnt even realize he was doing that. By including the PHP file via HTTP, you are including the OUTPUT of the PHP file, not the actual PHP file itself. e.g. by including a file with the following code: ?PHP print 'Hello'; ? you would be including the word Hello as PHP code, which is obviously going to cause a syntax error. Yes. I read the manual which provides no clear explanation (I suspect that whoever wrote it didn't actually know how it works). So I decided to test it. It does exactly what you say it does. I made an include file like this: ?php echo '?php echo Hello World!; ?'; ? If you inlude that using HTTP, it outputs Hello world! Seems like a strange thing to do, outputting PHP code on a Web page, but it's not without conceivable usefulness. -Original Message- From: Dagfinn Reiersl [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 10:18 AM To: PHP General Subject: Re: [PHP] Syntax Error - This is WEIRD! Nick Wilson wrote: if a script calls antohter like 'include('http://site.com/index.php'); Why would I get a syntax error on line 1 of index.php when it looks like this: ?php // line one above this one What's the deal there? Many thanks for any insight ;-) I've never tried to do an include via HTTP, so maybe I'm clueless, but it occurs to me that it might be a good idea to try doing a plain old file include, using exactly the same file. I have the feeling it would be interesting to know whether that would work or not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php