/    Sign up×
Community /Pin to ProfileBookmark

Why This Cannot Redeclare Function Error ?

This is just downright ridiculous!

Can someone tell me why I get this ridiculous error ?
**Fatal error: Cannot redeclare filter_input() in C:xampphtdocsTemplatestest.php on line 12**

Where on earth am I redeclaring the filter_input() ?
Check my code and notice the code comment.

[code]
<?php

$input = ‘<a href=”http://www.site.com/index~1.html”>http://www.site.com/index~1.html</a>’;

function filter_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);

return $data;
} //LINE 12 is here. Where am I redeclaring filter_input() on this line ?

echo filter_input($input);

echo $input;
echo ‘<br>’;
echo $data;

die;

?>

[/code]

Stopped and restarted my local webserver. Shut down and re0opened FireFox. Same issue.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 16.2021 — PHP Manual again: https://www.php.net/filter_input is a pre-defined function. You cannot re-define it.
Copy linkTweet thisAlerts:
@developer_webauthorApr 17.2021 — @NogDog#1630478

I soon figured that out during my tests. Thanks for the link though.

No wonder the tutorial named the function test_input(). I had just renamed it to filter_input().
×

Success!

Help @developer_web 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 4.19,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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