What is the best way to handle PHP blending in Javascript? Shouldn't this be done? Should this be done in a certain way? I am working on a project and I found the following javascript function:
function getStuff() {
<?php
$stuff = "0:Select";
foreach ($this->stuff as $k => $v){
$stuff = $stuff . ";" . $v['stuff_id'] . ":" . $v['stuff_name'];
}
?>
return "<?= $stuff ?>";
}
Assuming I need the data that PHP provides, what is the ideal way to get it? I don’t think so, but the person who wrote it is my boss, so I want to ask before I try to change it.
FYI, this JS is used in the script view, and the data for is $this->stufftransmitted from the controller that uses it.
source
share