Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Quick PHP Question

LEGEND ,
Apr 19, 2006 Apr 19, 2006
SOrry about the simple ques.

I'm creating a function that already has a variable defined. Will I be
redefining this variable when I define my function and include it?

Example:

$varDate = Recordset

function priivaDate ($varDate) {
$varDate +1;
return $varDate;}

I'm guessing my answer is I'm all clear, but I just want to make sure.

--

Thanks,
Jon


TOPICS
Server side applications
302
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
.oO(crash)

>I'm creating a function that already has a variable defined. Will I be
>redefining this variable when I define my function and include it?
>
>Example:
>
>$varDate = Recordset
>
>function priivaDate ($varDate) {
> $varDate +1;
> return $varDate;}
>

Why not simply test it or look it up in the manual?

The second $varDate is only visible within the context of the function.
It won't affect the global variable, unless that one is imported into
the function using the 'global' keyword. From the manual:

| [...] However, within user-defined functions a local function scope is
| introduced. Any variable used inside a function is by default limited
| to the local function scope.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
LATEST
I had. I was using a recordset I had forgot to reset before use. (hence,
where I thought it was resetting the variable, it was simply out of info).
I was being an idiot. I've got it now. I was just checking to post back my
mistake, lol.

Thanks anyway, Micha!


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines