php method to determine the origin and jump: first create a PHP sample file; then implement the judgment logic through if statements and strpos and other functions; finally run the file to determine the origin link and make the corresponding jump change.
php determines the source and jumps
<?php if(strpos($_SERVER['HTTP_REFERER'],'baidu.com')===false){ //不是从百度过来的 header('Location: http://www.c.com/somepage.php'); } ?>
Related introduction:
strpos( ) function finds the first occurrence of a string within another string.
Note: The strpos() function is case-sensitive.
Note: This function is binary safe.
Related functions:
stripos() - Find the first occurrence of a string in another string (not case sensitive)
strripos() - Find the last occurrence of a string in another string (case-insensitive)
strrpos() - Find the last occurrence of a string in another string (case-sensitive)
Syntax
strpos(string,find,start)
Parameters
string Required. Specifies the string to search for.
find Required. Specifies the string to search for.
start Optional. Specifies where to start the search.
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to determine the origin and jump in php. For more information, please follow other related articles on the PHP Chinese website!