Using PHP within Javascript functions

pixelpro321

New Member
What is the best way to handle mixing PHP into Javascript? Should it not be done? Should it be done in a certain way? I am working on a project and I found the following javascript function: \[code\]function getStuff() { <?php $stuff = "0:Select"; foreach ($this->stuff as $k => $v){ $stuff = $stuff . ";" . $v['stuff_id'] . ":" . $v['stuff_name']; } ?> return "<?= $stuff ?>"; }\[/code\]Assuming I need the data that the PHP is providing what is the ideal way to get it? This doesn't seem like it to me but the person that wrote this is my boss so I want to ask before trying to change it.FYI, this JS is used in a view script and the data for \[code\]$this->stuff\[/code\] is passed in from the controller that uses it.
 
Back
Top