如何在php中删除URL参数字符串的一部分

问题描述:

Why does this not remove the example/ :

$url = "http://webserver/exmaple/subdomaine/";
$domaine="example"
$domaine= $domaine."/";
echo str_replace($domaine,"",$url);

Is there a better way to do so ?

Thanks!

为什么这不会删除 example / code>: p>

  $ url =“http:// webserver / exmaple / subdomaine /”; 
 $ domaine =“example”
 $ domaine = $ domaine。“/”; 
echo str_replace($ domaine,“  “,$ url); 
  code>  pre> 
 
 

有更好的方法吗? p>

谢谢! p> \ n div>

$domaine = "example"; // Missing semicolon ...

Check spelling:

exmaple !== example

exmaple would be a tree that was a maple in the past but is now another type of tree such as an oak or yew.

did a mistake here

$domaine="example"

replace it by

$domaine="example";