找到你要的答案

Q:What does Predefined constant mean in PHP for a module like trader

Q:什么是预定义的常数平均在PHP模块像贸易商

I am using this module PHP trader.

I am not able to understand what "Predefined constant" means. Should we define these before we call the functions? Should we define them as numbers, or is there no need to mention them before calling the functions?

http://php.net/manual/en/trader.constants.php:

Predefined Constants - The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

我使用这个模块的PHP贸易商。

我无法理解“预定义常数”是什么意思。我们应该在调用函数之前定义这些吗?我们应该将它们定义为数字,还是在调用函数之前不需要提及它们?

http://php.net/manual/en/trader.constants.php:

预定义常数-以下常量由此扩展定义,并且只可在扩展已被编译成PHP或在运行时动态加载。

answer1: 回答1:

No, you don't have to define anything.

The predefined constants are defined by the extension, so that you can use symbolic names rather than "magic" constants. For example, you would write:

$a = trader_ma ($real, $period, TRADER_MA_TYPE_DEMA);

which carries more meaning to the reader than

$a = trader_ma ($real, $period, 42); /* to pick a random number */

that just contains some mysterious number that you have to look up in a manual every time you read it.

不,你不需要定义任何东西。

预定义常量由扩展名定义,以便您可以使用符号名而不是“魔术”常量。例如,你会写:

$a = trader_ma ($real, $period, TRADER_MA_TYPE_DEMA);

给读者带来更多的意义

$a = trader_ma ($real, $period, 42); /* to pick a random number */

这只是包含一些神秘的数字,你必须查找手册,每次你读它。

php  constants  class-constants