Question: I want to make some thing like this

**my-php-file.php**

```
  $lang = 'es';

```

**my-js-file.js**

```
if ($lang == es)
   {
   something-magical-happens;
   }

```

or like this:

```
if (URL == www.mydomain.com/index.php?lang=es)
   {
   something-magical-happens;
   }

```

Answer: 
you could generate js *on-the-fly*

my.js.php:

```
<?php echo "//Yes." ?>
var i = "<?php echo $_GET['lang']; ?>";

function doSomethingWithI(){
  alert(i);
}

```

Now, try to include

```
<script type="text/javascript" src="my.js.php?lang=es"></script>

```

in your html and you'll see :)

**Edit:** Check it in action here: <http://h.kissyour.net/so/phpjs/>

**Edit:** Edited example on my server to closer resemble what I wrote here.

**Edit:** Oh yes. **Don't forget to clean your code!**
In this specific case, why not simply properly set the document language and then look at that using JavaScript?

```
<html lang="es">
```

And in the script:

```
if (document.documentElement.getAttribute('lang') === 'es') { alert('Spanish'); }
```