我已经constants.php在Silex中使用composer自动加载了文件。
constants.php
<?php
define('SENT_SUCCESS_','Chat Transcript has been successfully sent');
define('INVALID_CASE_NUMBER','Invalid Case Number');
define('INVALID_FILE_EXTENSIONS','Following attachment(s) couldn\'t be uploaded with this chat due to an Invalid Extensions');
?>
我想index.html.twig在js<script />标记的文件中访问它。我们可以轻松地在js中使用php变量,但是我不知道如何使用php常量。我尝试了这个,但是没有在工作index.html.twig。
<script>
const INVALID = '{{INVALID_FILE_EXTENSIONS}}';
</script>
任何人都有主意,如何获取此变量?
眼眸繁星