Help js code mixed with php code usage exception
sun
sun 2022-08-21 10:59:48
0
8
1141

How to call the php function in js, js passes in the variable, and the php function returns it to the js variable after processing. I can't read what I wrote. , error report,. It's OK to apply script to PHP, but it won't work if you apply script to PHP. . Specifically, I want to know how to directly transfer variables

<script> var a="1001"; var op='666'; od="<?php $b=op; echo jia($b) ; a variable: '.$b; function jia($c){ //$c="<script>document.write(op)</script>"; return $c.'---8888'; } ?>

sun
sun

reply all(4)
sun

<script>

var a='1001';

var op='666';

od="<?php $bb=' 888'; $b='<script>document.write(op)</script>'; echo jia($b);

##</script><?php                                                                                                                 ';

echo 'a variable:'.$b;

function jia($c){

return $c.'---8888';

}

?>

I mainly want to get the js variables in js and return them after execution in php. . .

  • reply When php is executed, only the code inside will take effect. The code outside the tag cannot be obtained. You can submit the data to this page through JS, pass the variables to php, php will process it, and then pass it out.
    autoload author 2022-08-21 15:31:36
autoload

If you want to pass a value, you can use session

autoload

As I told you, the PHP code is executed first

image.png

The op variable is not defined in PHP

  • reply var a='1001'; var op='666'; od=""; document.write(od); I mainly want to execute the js variable agricultural loan php in js and return it. . .
    sun author 2022-08-21 15:20:36
autoload

Parse PHP first, then parse JS

  • reply Sir, can you help me see where I made a mistake here? Can it be used if I correct it?
    sun author 2022-08-21 13:35:53
  • reply Why don't you format your code? I can't understand it.
    autoload author 2022-08-21 15:10:08
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template