Can i load javascript from php file?
Can I do something like this?
<script src="/js/custom-user.php" type="text/javascript"></script>
The reason for this is because I want the .php file to die () when the user is not logged in, so that other visitors (not authenticated) cannot see what javascript looks like. Is it possible / safe to do this?
, . -, , , <script>, . , , , js, , .
js PHP, :
header("Content-type: text/javascript");
// either readFile or custom stuff here.
echo "alert('i canz have data!')";
// or, if you're less silly
readFile('/path/to/super-secret.js');
, - CSS PHP (, ), get. :
rel="stylesheet" type="text/css" href="css.php?v=#FF0000">
#FF0000 , -. , imagemagick . , , .