PHP 代码如果 url 的一部分包含 *this* 则执行 *this*

PHP code if part of url contains *this* then do *this*

我有一个 joomla 网站。我有一个 index.php,其中包含 PHP 显示 divs 的代码 + HTML 带有 divs

的代码

我还有另一个 index.php 应该继续使用 /en 和 /fr 版本。 我还有上面描述的 index.php 的另一个版本。我需要在 /ru 版本上显示一个 index.html,在 /en+/fr 版本上显示另一个

换句话说,我需要回显 mysite.com/ru 中的一些代码和 mysite.com/en + mysite.com/fr

中的另一个代码
<?php
$url = "http://mysite/en/";
$currentpage = $_SERVER['REQUEST_URI'];
if($url==$currentpage) {
echo 'index.html version one'
?>

但这没有用。

使用strpos():-

if(strpos($url ,'en/') !== FALSE || strpos($url ,'fr/') !== FALSE) {
echo 'index.html version one';
}
if(strpos($url ,'ru/') !== FALSE){
echo 'index.html version two';
}

示例link:- https://eval.in/734505

参考:-http://php.net/manual/en/function.strpos.php

再次感谢。 这是我的解决方案:-

<?php 
$url = $_SERVER['REQUEST_URI']; 
if(strpos($url ,'en/') !== FALSE || strpos($url ,'fr/') !== FALSE) { ?> 
<div>my code for en+fr</div> 
<?php } else { ?> 
<div>my code for ru</div> 
<?php } ?>