FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » initial value
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: initial value [message #171198 is a reply to message #171180] Wed, 29 December 2010 11:48 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
Norman Peelman wrote:
> Denis McMahon wrote:
>> On 28/12/10 17:15, richard wrote:
>>> On Tue, 28 Dec 2010 17:44:48 +0100, Luuk wrote:
>>>
>>>> On 28-12-10 17:30, richard wrote:
>>>> > $year=
>>>> > echo $year
>>>> >
>>>> > Works just fine except for one thing.
>>>> > When the page is initially loaded, there is nothing in the space.
>>>> > I want to show a year in the space as the default.
>>>> > So that $year should have a value other than null.
>>>> > How is that done?
>>>> if (isset($_GET(yearID)) {
>>>> $year=$_GET(yearID)
>>>> } else {
>>>> $year=2010
>>>> }
>>>>
>>>> http://php.net/manual/en/function.isset.php
>>> Thanks for the offer. Just one problem, I get this error message.
>>> Fatal Error, Can't use function return value in write context.
>>
>> // default value
>> $year = "2020";
>> // over-ride with content of get if defined
>> if (isset($_GET["yearID"])) $year=$_GET["yearID"];
>>
>> Rgds
>>
>> Denis McMahon
>
> $year = isset($_GET['yearID']) ? $_GET['yearID'] : date('Y');
>

I should add that you should ensure that $_GET['yearID'] (or $year at
this point) actually contains what you think it should by use of a
sanitizing function as well.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem Connecting to PHP
Next Topic: Open Session Variables
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 20:36:03 GMT 2024

Total time taken to generate the page: 0.06388 seconds