包括JS功能



在我工作的项目中,有一个具有JS功能的PHP文件:

<script type="text/javascript">
  function alertaProximaBloqueada(){
    [...]
  }
  function ManualAluno() {
    [...]
  }
  [...]
</script>

此文件包含在使用这些功能的视图末尾,例如:

</body>
<?php include 'Includes/funcoes_ameai.php';?>

quando olho nocódigofonte com o crtl u asfunçãesestãoTodasLá,Mas Quando Tento tento executar Qualquer uma,Recebo Esse Erro:

未介绍的参考:nome_da_funcao尚未定义 [...]

最奇怪的是,如果我将功能复制并粘贴在所包含的位置,在视图内(在标签之间),我可以正常执行它。

尝试将脚本放在html的头部。

除了使用括号: include('Includes/funcoes_ameai.php');

将您的Include语句放入您的 HEAD e节

<html>
<head>
<?php include 'Includes/funcoes_ameai.php';?>
<title>do not forget to give a title</title>
</head>
<body>
</body>
</html>

最新更新