PHP 操作顺序

发布于 2024-08-23 19:24:19 字数 166 浏览 3 评论 0原文

我想知道 PHP 如何执行这个。操作顺序

addslashes(strip_tags($record['value']));

首先调用addslashes 还是先调用strip_tags?

换句话说,它是从内向外执行还是从外向内执行?

I wanted to know how PHP would execute this. Order of operations

addslashes(strip_tags($record['value']));

Is addslashes called first or strip_tags?

In other words, does it execute from the inside out or from the outside in?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

老子叫无熙 2024-08-30 19:24:19

从内到外。

PHP 中传递给函数的东西称为“表达式”。当您将表达式作为参数传递时,您真正传递的是该表达式的值。为此,在传入表达式之前对其进行求值。

有关表达式的更多信息,请参见 php 手册

From the inside out.

The things passed into a function in PHP are called "expressions". When you pass an expression as a parameter, what you're really passing is the value of that expression. In order to do that, the expression is evaluated before it is passed in.

More about expressions from the php manual.

雨巷深深 2024-08-30 19:24:19

strip_tags 首先被调用。

这不仅是 PHP 的情况,也是所有其他编程语言的情况(不包括一些晦涩难懂的语言,它们可能具有某些独特的求值顺序)。

PS:这里有一些文档:PEDMAS。这也是编程语言中这种评估顺序的灵感来源。

strip_tags is called first.

and this is not just the case with PHP, it is the case with every other programming language (excluding some obscure esoteric language that may have some unique order of evaluation).

PS: Here is some documentation: PEDMAS. This is what inspired this kind of evaluation order in programming languages too.

太阳男子 2024-08-30 19:24:19

如果您以逻辑方式思考,PHP 需要什么才能执行该函数?变量。因此,strip_tags 需要先输入 $record['value'],然后才能执行该函数并从中剥离标签。该函数将返回一个值。

现在,addslahes 也需要一个变量。它不能在函数上执行,它需要内部的函数返回一些东西来供它处理。因此它使用从 strip_tags 返回的值作为变量并执行。

If you think about it in a logical way, what does PHP need in order to execute the function? The variable. So, strip_tags needs the $record['value'] to be inputted before it can execute the function and strip the tags from it. That function will return a value.

Now, addslahes needs a variable too. It cannot execute on a function, it needs that function inside it to return something for it to process. So it uses that returned value from strip_tags as its variable and executes upon that.

心的憧憬 2024-08-30 19:24:19

addslashes 采用一个参数,在您的情况下,它是 strip_tags($record['value'])
当参数未解析时,无法调用 addslashes

因此必须首先调用strip_tags。几乎所有流行的编程语言都是这种情况。我想知道你在知道这一点之前是如何度过的!

addslashes takes one argument, in your case it is strip_tags($record['value']).
addslashes can't be called when it's argument isn't resolved.

Therefore strip_tags must be called first. This is the case in nearly all popular programming languages out there. I wonder how you managed to get by before knowing this!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文