Nope, PHP and Javascript are not compatable together; one is a server side language while the other is client side. Using Javascript you can create an AJAX request to a PHP page for its new variable information.
Aside from that, if the data is not dynamic you can generate the javascript itself using php and include it in as if it were javascript
:
CustomJS.php
PHP Code:
<?php
header("Content-type: text/javascript");
$a = aaaaaaaaaaaaa;
$b = bbbbbbbbbbbbbbbb;
?>
function validatePhone(fld) {
var error = "";
var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');
if (fld.value == "") {
error = "You didn't enter a phone number.\n";
fld.style.background = 'Yellow';
} else if (isNaN(parseInt(stripped))) {
error = "The phone number contains illegal characters.\n";
fld.style.background = 'Yellow';
} else if (!(stripped.length == 10)) {
error = <?php echo $a . PHP_EOL;?>
fld.style.background = 'Yellow';
}
return error;
}
Code:
<head>
<script type="text/javascript" src="path/to/CustomJS.php"></script>