Home >Backend Development >PHP Tutorial >Output js statements in php - Blue Moon

Output js statements in php - Blue Moon

不言
不言Original
2018-03-30 14:40:146144browse

This article shares with you how to output js statements in PHP. Friends in need can refer to it

How to output js statements in PHP?

Example

php<?php
$classState="";

if($state==0){
$classState="已下课";
}
else{
$classState="正在上课";
}

echo "<script  type=&#39;text/javascript&#39;>
function getState(){            
        var cs = ".$state.";
        return cs;
} 
</script>";

?>

In this way, you can directly reference the js method output in php in other places on the page.


The above is the detailed content of Output js statements in php - Blue Moon. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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