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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -