![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Here's part of a problematic script from a counter. <?php $string = "Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.4) Gecko/20030624"; echo "$string\n<br>"; function searchid($search) { $pos = strpos($string, $search); if($pos) return true; else return false; } if (searchid("Gecko")) echo "you are using a gecko browser"; else echo "you are not using a gecko browser"; ?> It returns the false everytime, even though it's clear that Gecko is present in the string. It's demontrated at http://mikewilcox.t35.com:8000/truefalse.php -- Michael Wilcox Essential Tools for the Web Developer - http://mikewilcox.t35.com mjwilco at yahoo dot com | |||
|
| | #2 | ||
| Tom Thackrey <tomnr@creative-light.com> wrote: > It's time to learn about variable scope. The variable $string in the > function searchid is not the same as the $string you initialized and > echo'd. > > Variables in a function are local to that function unless they are > explicitly declared as global (or are one of the super-global > variables). > > Add the following line to your function: > global $string; You're wonderful, you saved a lot of wasted time. :-) -- Michael Wilcox Essential Tools for the Web Developer - http://mikewilcox.t35.com mjwilco at yahoo dot com | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: anoying, little, thing, trueflase |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Have you seen this... thing | Chilipeppers | Community Chat | 4 | 10-29-2007 9:38 AM |
| my thing didnt come up | Rodney | Software Programming | 0 | 06-12-2007 11:34 PM |
| Ipod thing | nick | Ebay Technical Questions | 4 | 05-31-2007 1:17 AM |
| The next best thing? | Chilipeppers | Computer Consoles | 5 | 07-31-2006 1:05 AM |
| What would be the first thing you would check? | Stickster | Computer Hardware | 6 | 05-22-2006 7:34 PM |
| Featured Websites | ||||
|