js and php nesting

jacklove
Release: 2023-04-01 11:50:01
Original
6251 people have browsed it

JavaScript and PHP can be nested in each other, provided that JavaScript is written in a file with the .php suffix.

# (1) Javascript nested PHP:

# directly in javascript PHP statements, such as:

Copy after login

(2) PHP nesting JavaScript:

';
	echo " BUI.use('bui/grid',function (Grid) {";
	//表单的数据内容
	echo 'var data = [';
	foreach($slice_rows as $key=>$val){
		echo "{id:'".$val['id']."',imgpath:'".$val['imgpath']."',introduction:'".$val['introduction'].
                     "',linkpath:'".$val['linkpath']."',date:'".$val['date']."'},";
	}
	
	echo "{id:'1112',imgpath:'李四',introduction:'1349622209547',linkpath:'#',date:'date2'}";
	
	echo '],';
	//表单的头部信息
	echo "
	 grid = new Grid.SimpleGrid({
          render : '#grid', //显示Grid到此处
          width : 950,      //设置宽度
          columns : [
            {title:'编号',dataIndex:'id',width:80},
            {title:'图片路径',dataIndex:'imgpath',width:100},
			{title:'简介',dataIndex:'introduction',width:200},
			{title:'链接地址',dataIndex:'linkpath',width:100},
            {title:'上传日期',dataIndex:'date',width:100}
          ]
        });
	
	";
	echo '  grid.render();
			grid.showData(data);
			});
  ';
	
	
	//echo 'alert("this is a test")';
	echo '';
	
?>
Copy after login

This article explains js and php nesting , please pay attention to php Chinese website for more related content.

Related recommendations:

js prevent default events and js prevent event bubbling examples share js prevent bubbling events

js common functions The writing method and the calling method

The whole process of reading json by AJAX in native JS

The above is the detailed content of js and php nesting. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!