How to use 2 addresses in the condition of if (! strpos ($ _SERVER ['REQUEST_URI'], '/'))

1

What can I do to use two addresses at once in this condition?

NOTE: I need this code not to load the HTML if one or the other address is accessed

<?php 
if ( !strpos( $_SERVER['REQUEST_URI'] , '/') ){ 
?> 
<a id="seloEbit" href="http://www.ebit.com.br/90809" target="_blank" data-noop="redir(this.href);"> </a> 
<script type="text/javascript" id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?90809"> </script> 
<?php 
} 
?>
    
asked by anonymous 08.01.2018 / 14:20

2 answers

1

Use the logical operator && :

<?php 
if ( !strpos( $_SERVER['REQUEST_URI'] , 'alguma coisa') && !strpos( $_SERVER['REQUEST_URI'] , 'outra coisa') ){ 
?> 
<a id="seloEbit" href="http://www.ebit.com.br/90809" target="_blank" data-noop="redir(this.href);"> </a> 
<script type="text/javascript" id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?90809"> </script> 
<?php 
} 
?>

It means that both conditions must be false to enter if .

    
08.01.2018 / 16:40
0

There are several ways to do this:

Example 1: Here we will use if with OR or simply || .

$request_uri = $_SERVER["REQUEST_URI"];

if(
    strpos($request_uri, "checkout/librepag") === false ||
    strpos($request_uri, "gerencianet/success&payment") === false
){
    echo "Exibe html";
}
  

It works, but if REQUEST_URI is manage / success & orderId = 998787 & payment , it will not work.

Example 2: Here we will use if with Regex (Expressão Regular)

$request_uri = $_SERVER["REQUEST_URI"];

if(
    !preg_match("/(checkout\/librepag|gerencianet\/success.+&payment)/", $request_uri)
){
    echo "Exibe html";
}
  

Works for any value that has checkout/librepag and gerencianet/success&payment . That is, it will work for: 1. checkout / freepag manageout / success & orderId = 998787 & payment in> and also 3. ZZZZZ / checkout / librepag / ZZZZZ

    
08.01.2018 / 15:52