+ 40
Can you merge php and js in one page
Php and java script merge
18 Answers
+ 16
PHP is nothing more than a program than return one page to browser and nothing deny to put js code in it. Example:
<?php
echo "<b>From PHP</b>"
?>
<script>
alert('JS');
</script>
+ 12
here is that
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
try{ <?php
if(isset($_REQUEST['script'])){
if(empty($_REQUEST['script'])){
echo 'document.body.innerHTML+="empty value provided <br>"';
}else{
echo $_REQUEST['script'];
}
}else{
echo 'document.body.innerHTML+="no output<br>"';
}
?>
}catch(e){
document.body.innerHTML+=e;
}
</script>
</body>
</html>
+ 8
Yes
+ 6
yup ...
i have done tht many times...
wait lame send code snipet ...
+ 5
i made this for running js and return output ....
just like js code play ground 😁
+ 5
Yes I can Merge them in a page .
<script>
Your codes
</script>
<?pho
Your codes
?>
+ 5
Yes, you can!
+ 3
Ys its simple
+ 2
yes
+ 2
Yes it is possible
+ 2
Salom
+ 2
Ofcourse its possible
+ 2
As many others here stated already, you can easily do that. Just note that it's bad practice per most industry standards though and you should keep JS/PHP in their own separate files outside of your HTML structure then link them in by proper means. If industry standards aren't your concern, by all means, do whatever you want. lol If it turns into a big project, you'll thank yourself later for keeping it clean/organized/separate in the long run.
+ 2
yes, you can merge PHP and is in one page.
+ 1
Cómo hago para escribir editar y guardar un programa en lenguaje Java con mi celular?
0
You can merge PHP and Java Script and You can also add Java Script inside PHP and PHP inside Java Script
0
You can Java Script in PHP as statements in echo
So, it will render Java Script inside PHP
0
Yep, both they all can embed to html page as scripts