I am trying to include javascript only when needed using a certain technique:

Pseudo code:

```
if ($this is included in x.php) {
<script>url to script</script>
}

```

I know that there is an is\_readable($fileurl) function and file\_exists ($fileurl). Im not entirely sure if I should use those and honestly even less how to make my javascript within the php if statement valid. Any ideas?