/    Sign up×
Community /Pin to ProfileBookmark

error: Undefined variable ??

Hi.

This is my code:

index.php
<? if($a)$naber=123; ?>

this is error:
Notice: Undefined variable: naber in C:Sunucuindex.php on line 1

Why appers the error? I think this is php.ini error but I dont know how can i patch this error.

help please ( sorry for bad english )

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@dreamcatcherMay 06.2006 — Its nothing to do with your PHP.ini file. Its because you haven`t defined the variable before you have used it.

Try:

<?

$naber = '';

if($a)$naber=123;

?>

dc


Hi.

This is my code:

index.php

<? if($a)$naber=123; ?>

this is error:

Notice: Undefined variable: naber in C:Sunucuindex.php on line 1


Why appers the error? I think this is php.ini error but I dont know how can i patch this error.

help please ( sorry for bad english )[/QUOTE]
Copy linkTweet thisAlerts:
@SpectreReturnsMay 06.2006 — Wrong. There's nothing wrong with that, except maybe that $a is undefined or you aren't showing us all the code.
Copy linkTweet thisAlerts:
@balloonbuffoonMay 07.2006 — Its just a notice, so its not anything big. I think you changed your code after you got that notice, because the notice should have read "Notice: Undefined variable: a in C:Sunucuindex.php on line 1". (Basically what SpectreReturns is saying.) At any rate, try changing the code to this:[code=php]if(isset($a))$naber=123;[/code]--Steve
Copy linkTweet thisAlerts:
@NogDogMay 07.2006 — Its just a notice, so its not anything big. I think you changed your code after you got that notice, because the notice should have read "Notice: Undefined variable: a in C:Sunucuindex.php on line 1". (Basically what SpectreReturns is saying.) At any rate, try changing the code to this:[code=php]if(isset($a))$naber=123;[/code]--Steve[/QUOTE]
Possibly you'll want to do...
[code=php]
if(!empty($a)) $naber = 123;
[/code]

...instead. Otherwise if $a is set but is False, 0, or "", isset() will still set $naber to 123, which may not be the desired logic.
×

Success!

Help @azerkoculu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...