3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name="why";//声明变量$name,并初始化 function echoName1() { //在函数echoName1()里使用global来声明$name global $name; echo "the first name is ".$name."<br>"; } function echoName2() { //在函数echoName2()里没有使用global来声明$name echo "the second name is ".$name."<br>"; } echoName1(); echoName2(); $last_name = "O'Keefe"; echo $sql = "select * from users where last_name = '" . addslashes($last_name) . "'"; class Person { //下面是人的成员属性 var $name; //人的名子 var $sex; //人的性别 var $age; //人的年龄 //定义一个构造方法参数为属性姓名$name、性别$sex和年龄$age进行赋值 function __construct($name = "", $sex = "", $age = "") { $this->name = $name; $this->sex = $sex; $this->age = $age; } //这个人可以说话的方法, 说出自己的属性 function say() { echo "我的名子叫:" . $this->name . " 性别:" . $this->sex . " 我的年龄是:" . $this->age . "<br>"; } } $p1 = new Person("张三", "男", 20); $p1_string = serialize($p1); //把一个对象串行化,返一个字符串 echo $p1_string . "<br>"; //串行化的字符串我们通常不去解析 $area_json_array=[[1,2],[3,4]]; echo json_encode($area_json_array, TRUE);
Output for git.master, git.master_jit, rfc.property-hooks
the first name is why<br> Warning: Undefined variable $name in /in/or5G5 on line 16 the second name is <br>select * from users where last_name = 'O\'Keefe'O:6:"Person":3:{s:4:"name";s:6:"张三";s:3:"sex";s:3:"男";s:3:"age";i:20;}<br>[[1,2],[3,4]]

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.52 ms | 401 KiB | 8 Q