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

Output js statements in php - Blue Moon

不言
Release: 2023-03-22 19:28:01
Original
6124 people have browsed it

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>";

?>
Copy after login

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!

Related labels:
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