How to determine the origin and jump in php

藏色散人
Release: 2023-03-01 21:32:01
Original
3976 people have browsed it

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.

How to determine the origin and jump in php

php determines the source and jumps

<?php 
    if(strpos($_SERVER[&#39;HTTP_REFERER&#39;],&#39;baidu.com&#39;)===false){
        //不是从百度过来的
        header(&#39;Location: http://www.c.com/somepage.php&#39;);
    }
?>
Copy after login

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)
Copy after login

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!

Related labels:
php
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