How to use ISSET (), empty (), is_numeric ()

Source: Internet
Author: User
Tags php tutorial

How to use ISSET (), empty (), is_numeric ()
Empty (); -- the best function.

Definition and scope of action: used to check whether a variable has a null value, including: null string, 0, null, or false, that is, "http: // localhost /? Fo = "or" http: // localhost /? When fo = 0 ", empty detects true and does not apply to values: 0.

Echo 'If (is_numeric ($ _ GET ['fo']) {// if the parameter does not contain the fo parameter, an error occurs.
Echo 'is_numeric of the variable/'Fo/'is true, a number ';
} Else {
The is_numeric of echo 'variable/'Fo/'is false, not a number ';
}

Empty (); -- the best function.

Echo 'If (empty ($ _ GET ['fo']) {
Echo 'empty of variable/'Fo/'is true, that is, null or invalid value ';
} Else {
The empty of echo 'variable/'Fo/'is false and has a value ';
}

ISSET () function

If (isset ($ a) echo 'isset of variable $ A' is true ';

Echo 'If (isset ($ _ GET ['fo']) {
Echo 'isset of variable/'Fo/'is true and the variable is usable ';
} Else {
Echo 'isset of variable/'Fo/'is false and no variable settings ';
}

Php Tutorial code

<P>
<A href = "? Fo = Jack "> pass valid values </a> <a href = "? Fo = "> pass null values </a> <a href = "? Fo = 0 "> 0 </a>
<Br/>
<A href = "? Sex = m "> Gender: Male </a> <a href = "? Sex = f "> Gender: Female </a>
<Br/>
<A href = "/"> clear </a>
<Br/>
<Input type = "text" value = "<? Php echo $ _ GET ['fo']! = ''? $ _ GET ['fo']: '';?> "Size =" 155 "/>
</P>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.