开发者

Using php as external javascript with CakePHP?

开发者 https://www.devze.com 2023-01-29 23:52 出处:网络
PHP files can b开发者_开发百科e used as external javascript files. Basically make a php file output valid javascript and use that php file as your javascript file: http://www.javascriptkit.com/javatut

PHP files can b开发者_开发百科e used as external javascript files. Basically make a php file output valid javascript and use that php file as your javascript file: http://www.javascriptkit.com/javatutors/externalphp.shtml . Can this be done with cakephp since we don't specify php files in the browser but rather a directory based on controllers and their actions?


Late answer, but anyway, this is how I did it.
When linking to external javascript file, don't forget to set inline to false like the one shown below:

$this->Html->script('scriptname', array('inline' => false));


Sure, as long as you output valid JS, id does not matter what the URL looks like and what is behind that URL.


When you link a javascript file with

$this->Html->script('scriptname');

all that happens is that a tag is created in the HTML

<script type="text/javascript" src="path/to/webroot/js/scriptname.js"></script>

So, you can link whatever you'd like.

0

精彩评论

暂无评论...
验证码 换一张
取 消