新手有一個有關(guān)問題很糾結(jié)
Jun 13, 2016 pm 01:06 PM
新手有一個問題很糾結(jié),請教各位
為什么下面這段代碼我無論輸出什么都會顯示登錄密碼錯誤呢??用var_dump($num1)發(fā)現(xiàn)無論html那邊num1輸入什么,$num1和$num2都是string類型
$num1=$_REQUEST['num1'];
$num2=$_REQUEST['num2'];
if(is_string($num1))
{
if(is_int($num2))
{
echo"歡迎您的登錄"
}
else
{
echo"登錄密碼錯誤"
}
}
else
{
echo"您的用戶名格式錯誤"
}
?>
------解決方案--------------------
從html那邊提交過來的數(shù)據(jù)一般都是string的.
if(is_int($num2))
{
echo"歡迎您的登錄"
}
else
{
echo"登錄密碼錯誤"
}
$num2是stirng類型,所以顯示"登錄密碼錯誤"
------解決方案--------------------
是的,form 提交過去的都是字符串。你應(yīng)該用 is_numeric() 來檢測更為恰當(dāng)。
------解決方案--------------------
都有,前臺可進行一般驗證。但是為了安全性在后臺驗證也有必要性。
------解決方案--------------------
if(!preg_match('/^\d+$/',$num1)
echo '純字符串';

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Convert basic data types to strings using Java's String.valueOf() function In Java development, when we need to convert basic data types to strings, a common method is to use the valueOf() function of the String class. This function can accept parameters of basic data types and return the corresponding string representation. In this article, we will explore how to use the String.valueOf() function for basic data type conversions and provide some code examples to

Method of converting char array to string: It can be achieved by assignment. Use {char a[]=" abc d\0efg ";string s=a;} syntax to let the char array directly assign a value to string, and execute the code to complete the conversion.

Replace characters (strings) in a string using Java's String.replace() function In Java, strings are immutable objects, which means that once a string object is created, its value cannot be modified. However, you may encounter situations where you need to replace certain characters or strings in a string. At this time, we can use the replace() method in Java's String class to implement string replacement. The replace() method of String class has two types:

Use Java's String.length() function to get the length of a string. In Java programming, string is a very common data type. We often need to get the length of a string, that is, the number of characters in the string. In Java, we can use the length() function of the String class to get the length of a string. Here is a simple example code: publicclassStringLengthExample{publ

The most popular Go frameworks at present are: Gin: lightweight, high-performance web framework, simple and easy to use. Echo: A fast, highly customizable web framework that provides high-performance routing and middleware. GorillaMux: A fast and flexible multiplexer that provides advanced routing configuration options. Fiber: A performance-optimized, high-performance web framework that handles high concurrent requests. Martini: A modular web framework with object-oriented design that provides a rich feature set.

In today's era of rapid technological development, programming languages ??are springing up like mushrooms after a rain. One of the languages ??that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets

Hello everyone, today I will share with you the basic knowledge of Java: String. Needless to say the importance of the String class, it can be said to be the most used class in our back-end development, so it is necessary to talk about it.
