0

is possible to call a php function with a js var? for example <?php print title(showResult(id); ?>

function showResult(id)
        {
              swal({
                 position: "top-end",
                 type: "success",
                 title: `<?php print title('+id+'); ?>  ${id}`,  
                 icon: 'success',
                 confirmButtonText: '<?php print $lang['accept']; ?>',
                 showConfirmButton: true,
              });
        }
Kizion
  • 3
  • 3
  • there is no PHP interpreter in any browsers – Mister Jojo Jul 24 '22 at 14:42
  • You can make an AJAX request to a PHP script and receive its response. But you can't directly interpret PHP client-side in the web browser, no. In many cases it's worth considering if you need the functionality in PHP code or should just implement it in JavaScript code. – David Jul 24 '22 at 14:43
  • 1
    As PHP runs on the server and JS on the client: No. There's no direct way of communication between JS an PHP. (The only way could be AJAX-Requests) – akrys Jul 24 '22 at 14:44
  • is possible to request from a php file with sweetalert? demo.php – Kizion Jul 24 '22 at 17:00
  • Request what? As mentioned above,.anytime you can run an ajax request,.you can call some php code – ADyson Jul 24 '22 at 18:00

0 Answers0