PHP simple method to obtain and determine the source of submission_php skills

WBOY
Release: 2016-05-16 19:54:08
Original
1219 people have browsed it

The example in this article describes how to simply obtain and determine the source of submission in PHP. Share it with everyone for your reference, the details are as follows:

echo $_SERVER['HTTP_REFERER'];

Copy after login

This gets the url of the previous page

For example, what you get is:

$url = http://www.weisuyun.com/nihao.html

Copy after login

Submissions from other pages will not be accepted
The code is as follows:

if(strpos($url,'http://www.weisuyun.com')){
echo '来源正确';
}else{
echo '来源不明';
}

Copy after login

The strpos method returns the position where the specified string appears for the first time, if not, returns false, and the subscript starts from 0

Supplement:

stripos() - Finds the first occurrence of a string within another string (case insensitive)
strripos() - Finds the last occurrence of a string within another string (case insensitive)
strrpos() - Finds the last occurrence of a string within another string (case sensitive)

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP ajax skills and applications", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "Introduction to PHP basic syntax tutorial", "Summary of PHP office document skills (including word, excel, access, ppt)", "php date and time usage summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary" , "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!