Is it possible to accomplish the same using JavaScript?
<?php
$url = $_SERVER['PHP_SELF'];
$needle = 'php';
if(strstr($url, $needle)){
$bool = true;
}
else{
$bool = false;
}
if($bool){
?>
Text
<?php
}else{
?>
Another text...
<?php
}
?>
Basically I need to display different HTML content depending on the current site. Some parts are being included into different sites.
EDIT:
Is it OK, to do it this way:
<script>
var url = document.URL;
var needle = 'test';
var bool = false;
if(url.indexOf(needle) != -1){
bool=true;
}
document.write(bla);
</script>
<table border="1">
<script>
if(bool){
document.write('<tr><td>abc</td><td>def</td></tr>');
}
</script>
<tr><td>ghi</td><td>jkl</td></tr>
</table>
I’m not sure about the JavaScript within the table…
Of course. Just use
location.href.indexOf("php") > -1to see if it’s there.