javascript - How to get string value from php function? -
i want execute function in php returns string couldn't find clear explanation.
i if answer example.
this php file, hello.php:
<?php function helloworld() { return "hello!"; } ?>
and let's javascript in html file
mainpage.html
<body> <script type="text/javascript"> sayhello() { alert(/*this want php call*/); } </script> <input type = "submit" onclick="sayhello()"/> </body>
what asking how can php , use functions in succesfully
do 1 thing, change mainpage.html
mainpage.php
.
so, mainpage.php
like
<?php function helloworld() { return "hello!"; } ?> <body> <script type="text/javascript"> sayhello() { alert('<?php echo helloworld()?>'); } </script> <input type = "submit" onclick="sayhello()"/> </body>
this work you.
Comments
Post a Comment