Home > Backend Development > PHP Tutorial > Sample code for variable interaction between PHP and javascript_PHP tutorial

Sample code for variable interaction between PHP and javascript_PHP tutorial

WBOY
Release: 2016-07-21 14:59:52
Original
1127 people have browsed it

This example is an example of interaction between PHP and JavaScript. The value in PHP is assigned to the JS variable. The premise is that the PHP variable must have a value, even if it is in a fake branch.

For example, $flags in php is true in this example. If the false statement in js is written as: $title_1.innerHTML = ""; an error will occur because $title is assigned an array in php

Although flags=="false" in php; $title is a string, the situation is that $title is an array, and the array cannot be displayed directly in the string of.

Copy code The code is as follows:

$string = "Heaven and Earth";
$flags = "";
if(strpbrk($string,"and")!=false){
$title = explode("and",$string);
$title_1 = $title [0];
$title_2 = $title[1];
$flags = "true";
}
else{
$title = $string;
$flags = "false";
}
?>

—>html
Copy code The code is as follows:










< /html>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328105.htmlTechArticleThis example is an example of interaction between PHP and javascript. The value in php is assigned to the js variable. The premise is that this php Variables must have values, even in false branches. For example, $flags in php is in this case...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template