Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP部分代码存在错误 #233

Open
victor-one opened this issue Apr 19, 2022 · 0 comments
Open

PHP部分代码存在错误 #233

victor-one opened this issue Apr 19, 2022 · 0 comments

Comments

@victor-one
Copy link

数据类型处代码错误
原代码如下:

	// 字符串
	$str = '123';

	// 字符串拼接
	$str2 = '123'.'哈哈哈';


	// 整数
	$numA = 1; //正数
	$numB = -2;//负数

	// 浮点数
	$x = 1.1;

	// 布尔
	$a = true;
	$b = false;

	// 普通数组:数组中可以放 数字、字符串、布尔值等,不限制类型。
	$arr1 = array('123', 123);
	echo $arr1[0];

	// 关系型数组:类似于json格式
	$arr2 = $array(`name`=>`smyhvae`, `age`=>`26`);
	echo $arr2[`name`];  //获取时,通过  key 来获取

应改为

	// 字符串
	$str = '123';

	// 字符串拼接
	$str2 = '123'.'哈哈哈';


	// 整数
	$numA = 1; //正数
	$numB = -2;//负数

	// 浮点数
	$x = 1.1;

	// 布尔
	$a = true;
	$b = false;

	// 普通数组:数组中可以放 数字、字符串、布尔值等,不限制类型。
	$arr1 = array('123', 123);
	echo $arr1[0];

	// 关系型数组:类似于json格式
	$arr2 = array('name'=>'smyhvae', 'age'=>'26');
	echo $arr2['name'];  //获取时,通过  key 来获取

类与对象处代码错误
原代码如下

	class Fox{

	        public $name = 'itcast';
	        public $age = 10;
	}

	$fox = new $fox;
	// 对象属性取值
	$name = $fox->name;
	// 对象属性赋值
	$fox->name = '小狐狸';

应改为

	class Fox{

	        public $name = 'itcast';
	        public $age = 10;
	}

	$fox = new Fox;
	// 对象属性取值
	$name = $fox->name;
	// 对象属性赋值
	$fox->name = '小狐狸';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant