Reputation: 82
I have a joomla site. I have an index.php that contains PHP code that displays divs + HTML code with divs
I have another index.php that should go on with /en and /fr versions. and I have another version of index.php that I described above. I need to display one index.html on /ru version and another one on /en+/fr versions.
In other words, I need to echo some code in mysite.com/ru
and another code on mysite.com/en
+ mysite.com/fr
<?php
$url = "http://mysite/en/";
$currentpage = $_SERVER['REQUEST_URI'];
if($url==$currentpage) {
echo 'index.html version one'
?>
But this didn't work.
Upvotes: 2
Views: 855
Reputation: 72299
Use 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';
}
Example link:- https://eval.in/734505
Reference:-http://php.net/manual/en/function.strpos.php
Upvotes: 5
Reputation: 82
Thank you again. Here is my solution:-
<?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 } ?>
Upvotes: 1