/*varchar(255)和varchar(256) 和 varchar(50)和varchar(100) 的区别*/

	$sql="create table char20(
		title char(20)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);

	$sql="create table char40(
		title char(40)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);

	$sql="create table varchar50(
		title varchar(50)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);

	$sql="create table varchar100(
		title varchar(100)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);

	$sql="create table varchar255(
		title varchar(255)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);

	$sql="create table varchar256(
		title varchar(256)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysqli_real_query($con,$sql);


//每个表插入百万数据
mysqli_autocommit($con,FALSE); //关闭自动提交
for ($i=1; $i<=50000; $i++){
	$t=time();
	mysqli_real_query($con,"insert into char20(title)values('{$t}')");
	mysqli_real_query($con,"insert into char40(title)values('{$t}')");
	mysqli_real_query($con,"insert into varchar50(title)values('{$t}')");
	mysqli_real_query($con,"insert into varchar100(title)values('{$t}')");
	mysqli_real_query($con,"insert into varchar255(title)values('{$t}')");
	mysqli_real_query($con,"insert into varchar256(title)values('{$t}')");
}
mysqli_commit($con); // 提交事务
echo "插入完毕!";

echo '<script type="text/javascript">window.location.href="mysqlceshi.php";</script>';

image.png

结论: 

varchar(50)和varchar(100)  占用空间没有任何区别

char(40) 刚好是 char(20) 的一倍

然后测效率: