Ben bir php kütüphanesi dosya ve bir javascript kitaplık dosyası dahil olduğum bir web sitesi var. Ben aşağıdaki dosyalar için sorun yoğunlaşmış:
index.php
<?php
include('constants.php');
?>
<html>
<head>
<script type="text/javascript" src="lib.js"></script>
</head>
<body onload="javascript:show_const_1('<?php echo(CONST_TEXT); ?>');
show_const_2();">
Some text here
</body>
</html>
constants.php
<?php
define('CONST_TEXT', 'Hello World');
?>
lib.js
function show_const_1(string)
{
alert(string);
}
function show_const_2()
{
alert('<?php echo(CONST_TEXT); ?>');
}
Sonuç yani sayfa yüklendiğinde iki mesaj kutularını olsun. İlk "Merhaba Dünya" diyor ve ikinci "
İkinci javascript yöntemi çalışması için kodu yeniden düzenlemek için iyi bir yolu var mı?