gpt4 book ai didi

php - 编码标准和行长

转载 作者:IT王子 更新时间:2023-10-29 00:00:53 26 4
gpt4 key购买 nike

我见过的每个编码标准都对一行中的字符数有推荐或绝对限制。在此限制范围内有多种工作方式,但我没有看到这方面的任何具体指导。

显然,如果可能的话,不要写太长的行。

但如果这不切实际怎么办?排长队应该如何处理?

这里有几个例子

if ($Stmt = $Mysqli->prepare("SELECT color, pattern, size,
manufacturer, mfgSku, storeLocation,
aisle, status
FROM tblItems WHERE ourSku = ?")) {

$flavors = array ('chocolate', 'strawberry', 'vanilla', 'cookie dough', 
'chocolate chip', 'mint chocolate chip', 'rocky road',
'peach', 'fudge brownie', 'coffee', 'mocha chip');

$Stmt->bind_result( $this->_firstName,
$this->_lastName,
$this->_BillToAddress->address1,
$this->_BillToAddress->address2,
$this->_BillToAddress->city,
$this->_BillToAddress->state,
$this->_BillToAddress->zip,
$this->_BillToAddress->country,
$this->_email,
$this->_status,
$this->_primaryPhone,
$this->_mobilePhone );

在每个示例中,冗长代码的缩进是不同的。有没有更好或更“标准”的方式来做到这一点?额外的行是否应该始终以相同的方式缩进。或者这样可以吗?

最佳答案

我个人的偏好如下;

$Stmt->bind_result(    $this->_firstName,    $this->_lastName,    $this->_BillToAddress->address1,    $this->_BillToAddress->address2,    $this->_BillToAddress->city,    $this->_BillToAddress->state,    $this->_BillToAddress->zip,    $this->_BillToAddress->country,    $this->_email,    $this->_status,    $this->_primaryPhone,    $this->_mobilePhone );

这样,右括号和分号与开始调用位于同一缩进位置。并非所有语言都支持在方法调用的另一行上使用参数......

关于php - 编码标准和行长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/566082/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com