![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Nov 2007
Posts: 27
Rep Power: 0
![]() |
Opposite of global in functions
Hi all,,
Another stupid question from me... I know that in order to use a variable from your main php within a function you need to use global $variable but I was wondering how you can set a variable within a function and get it to carry out into the main PHP. now I know a bit about return but I'm unsure how to return what I need... I thought about returning an array with 1 and my variable instead of true... but it's hard to evaluate when coming out of the function. Here's my code. all my functions are stored in an 'include' file but I have simplified what's going on: php Syntax (Toggle Plain Text)
and this code works fine except for the $daysold bit... it works within the function but outside of the function it does not work... so I thought maybe something like this: (I HAVE LEFT OUT MOST OF THE PHP FOR READABILITY AND ONLY SHOWN THe PARTS I THOUGHT I WOULD EDIT) php Syntax (Toggle Plain Text)
but I presume it would be much easier if I could just set a variable for $daysold within the function like in my first bit of code but have it stay outside the function... I have googled "php functions global" and a load of variations but I cannot find what I need. So is there a command I can use to set a variable within my function and get it to stay out in my main code, or should I use an array and call the function twice, as in my second bit of code? |
|
|
|
| Bookmarks |
| 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 |
| Writing Javascript functions for a Google Gadget? | Writlaus | JavaScript and Client-Side Browser Scripting | 3 | Jul 22nd, 2006 8:43 AM |
| binding between ordinary member functions & polymorphic member functions | ASH | C++ | 2 | May 11th, 2006 5:36 AM |
| Use C++ functions is VB.NET | userName123 | Visual Basic .NET | 1 | Oct 8th, 2005 9:32 AM |
| Exporting Functions | victorsk | Visual Basic | 1 | May 18th, 2005 3:32 PM |
| User-defined creatNode and deleteNode functions for a doubly-linked list | jgs | C | 2 | Apr 28th, 2005 9:53 AM |