PHP filter_var function outputs nothing











up vote
0
down vote

favorite












I have the following code:



$email = 'test@example.com';
echo $email.'<br>';
echo filter_var('test@example.com',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';


and it the output is as follows:



test@example.com
SANITIZED-EMAIL


Clearly the email is completely turned into an empty string. Similarly the filter_var with FILTER_SANITIZE_STRING does the same thing. What am I missing here?










share|improve this question
























  • didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
    – Kaddath
    Nov 12 at 11:00










  • your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
    – Akintunde-Rotimi
    Nov 12 at 11:14










  • Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
    – user1874354
    Nov 12 at 11:17















up vote
0
down vote

favorite












I have the following code:



$email = 'test@example.com';
echo $email.'<br>';
echo filter_var('test@example.com',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';


and it the output is as follows:



test@example.com
SANITIZED-EMAIL


Clearly the email is completely turned into an empty string. Similarly the filter_var with FILTER_SANITIZE_STRING does the same thing. What am I missing here?










share|improve this question
























  • didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
    – Kaddath
    Nov 12 at 11:00










  • your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
    – Akintunde-Rotimi
    Nov 12 at 11:14










  • Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
    – user1874354
    Nov 12 at 11:17













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have the following code:



$email = 'test@example.com';
echo $email.'<br>';
echo filter_var('test@example.com',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';


and it the output is as follows:



test@example.com
SANITIZED-EMAIL


Clearly the email is completely turned into an empty string. Similarly the filter_var with FILTER_SANITIZE_STRING does the same thing. What am I missing here?










share|improve this question















I have the following code:



$email = 'test@example.com';
echo $email.'<br>';
echo filter_var('test@example.com',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';


and it the output is as follows:



test@example.com
SANITIZED-EMAIL


Clearly the email is completely turned into an empty string. Similarly the filter_var with FILTER_SANITIZE_STRING does the same thing. What am I missing here?







php function filter-var






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 10:57









Bilal Ahmed

3,25631335




3,25631335










asked Nov 12 at 10:55









user1874354

28116




28116












  • didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
    – Kaddath
    Nov 12 at 11:00










  • your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
    – Akintunde-Rotimi
    Nov 12 at 11:14










  • Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
    – user1874354
    Nov 12 at 11:17


















  • didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
    – Kaddath
    Nov 12 at 11:00










  • your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
    – Akintunde-Rotimi
    Nov 12 at 11:14










  • Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
    – user1874354
    Nov 12 at 11:17
















didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
– Kaddath
Nov 12 at 11:00




didn't you mean FILTER_SANITIZE_EMAIL instead of FILTER_SANITZE_EMAIL (missing a I there)
– Kaddath
Nov 12 at 11:00












your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
– Akintunde-Rotimi
Nov 12 at 11:14




your code should have thrown an undefined constant. You should be including error_reporting(E_ALL); at the top of your script. of course after <?php ;)
– Akintunde-Rotimi
Nov 12 at 11:14












Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
– user1874354
Nov 12 at 11:17




Thank you Bilal. Yes that was the error I couldn't pick. It works as it should now.
– user1874354
Nov 12 at 11:17












1 Answer
1






active

oldest

votes

















up vote
2
down vote













Your code does give errors:




Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed
'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4



Warning: filter_var() expects parameter 2 to be long, string given in
/var/www/html/test.php on line 4 SANITIZED-EMAIL




It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo.






share|improve this answer

















  • 2




    probably you should flag this question as a typo. ;)
    – Akintunde-Rotimi
    Nov 12 at 11:15










  • Yes maio290 it is a typo. It works now thank you.
    – user1874354
    Nov 12 at 11:18










  • @Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
    – maio290
    Nov 12 at 11:21






  • 1




    @maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
    – Nick
    Nov 12 at 11:32










  • Thanks, @Nick - works :)
    – maio290
    Nov 12 at 12:25











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260657%2fphp-filter-var-function-outputs-nothing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Your code does give errors:




Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed
'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4



Warning: filter_var() expects parameter 2 to be long, string given in
/var/www/html/test.php on line 4 SANITIZED-EMAIL




It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo.






share|improve this answer

















  • 2




    probably you should flag this question as a typo. ;)
    – Akintunde-Rotimi
    Nov 12 at 11:15










  • Yes maio290 it is a typo. It works now thank you.
    – user1874354
    Nov 12 at 11:18










  • @Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
    – maio290
    Nov 12 at 11:21






  • 1




    @maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
    – Nick
    Nov 12 at 11:32










  • Thanks, @Nick - works :)
    – maio290
    Nov 12 at 12:25















up vote
2
down vote













Your code does give errors:




Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed
'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4



Warning: filter_var() expects parameter 2 to be long, string given in
/var/www/html/test.php on line 4 SANITIZED-EMAIL




It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo.






share|improve this answer

















  • 2




    probably you should flag this question as a typo. ;)
    – Akintunde-Rotimi
    Nov 12 at 11:15










  • Yes maio290 it is a typo. It works now thank you.
    – user1874354
    Nov 12 at 11:18










  • @Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
    – maio290
    Nov 12 at 11:21






  • 1




    @maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
    – Nick
    Nov 12 at 11:32










  • Thanks, @Nick - works :)
    – maio290
    Nov 12 at 12:25













up vote
2
down vote










up vote
2
down vote









Your code does give errors:




Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed
'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4



Warning: filter_var() expects parameter 2 to be long, string given in
/var/www/html/test.php on line 4 SANITIZED-EMAIL




It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo.






share|improve this answer












Your code does give errors:




Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed
'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4



Warning: filter_var() expects parameter 2 to be long, string given in
/var/www/html/test.php on line 4 SANITIZED-EMAIL




It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 11:00









maio290

1,605414




1,605414








  • 2




    probably you should flag this question as a typo. ;)
    – Akintunde-Rotimi
    Nov 12 at 11:15










  • Yes maio290 it is a typo. It works now thank you.
    – user1874354
    Nov 12 at 11:18










  • @Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
    – maio290
    Nov 12 at 11:21






  • 1




    @maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
    – Nick
    Nov 12 at 11:32










  • Thanks, @Nick - works :)
    – maio290
    Nov 12 at 12:25














  • 2




    probably you should flag this question as a typo. ;)
    – Akintunde-Rotimi
    Nov 12 at 11:15










  • Yes maio290 it is a typo. It works now thank you.
    – user1874354
    Nov 12 at 11:18










  • @Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
    – maio290
    Nov 12 at 11:21






  • 1




    @maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
    – Nick
    Nov 12 at 11:32










  • Thanks, @Nick - works :)
    – maio290
    Nov 12 at 12:25








2




2




probably you should flag this question as a typo. ;)
– Akintunde-Rotimi
Nov 12 at 11:15




probably you should flag this question as a typo. ;)
– Akintunde-Rotimi
Nov 12 at 11:15












Yes maio290 it is a typo. It works now thank you.
– user1874354
Nov 12 at 11:18




Yes maio290 it is a typo. It works now thank you.
– user1874354
Nov 12 at 11:18












@Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
– maio290
Nov 12 at 11:21




@Akintunde-Rotimi: I don't have the option, I can flag, but there is no option for a "typo" ;)
– maio290
Nov 12 at 11:21




1




1




@maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
– Nick
Nov 12 at 11:32




@maio290 you can flag as "should be closed", then select "off-topic", then you can select "problem that can no longer be reproduced or a simple typographical error"
– Nick
Nov 12 at 11:32












Thanks, @Nick - works :)
– maio290
Nov 12 at 12:25




Thanks, @Nick - works :)
– maio290
Nov 12 at 12:25


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260657%2fphp-filter-var-function-outputs-nothing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python