相关疑难解决方法(0)

Reference — What does this symbol mean in PHP?

What is this?

This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.

Why is this?

It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …

php arguments symbols operators

4314
推荐指数
21
解决办法
63万
查看次数

PHP变量与阵列对象

这可能被认为是一个非常愚蠢的问题,但我正在为一个网站组建一个简单的模板系统,并试图跟踪我的变量使用情况并保持一切都干净整洁.

你能告诉我以下方法是否有任何优点/缺点:

简单的var:

$tpl_title = 'my title'
$tpl_desc = 'my text'
Run Code Online (Sandbox Code Playgroud)

数组:

$tpl['title'] = 'my title'
$tpl['desc'] = 'my text'
Run Code Online (Sandbox Code Playgroud)

宾语:

$tpl->title = 'my title'
$tpl->desc = 'my text'
Run Code Online (Sandbox Code Playgroud)

我喜欢对象方法最好,因为它看起来很干净,当html中的echo而不是数组和afaik它可以以类似数组的方式使用?但是,我想知道的是,以这种方式使用对象是否被视为不良做法或引入不必要的开销?

php object

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

php ×2

arguments ×1

object ×1

operators ×1

symbols ×1