Home >Backend Development >PHP Tutorial >PHP simple method to obtain and determine the source of submission_php skills
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'];
This gets the url of the previous page
For example, what you get is:
$url = http://www.weisuyun.com/nihao.html
Submissions from other pages will not be accepted
The code is as follows:
if(strpos($url,'http://www.weisuyun.com')){ echo '来源正确'; }else{ echo '来源不明'; }
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.