为什么这个(面向对象的)php脚本没有返回值?

时间:2016-09-21 18:13:02

标签: php

以下是我在面向对象的php中编写的一个非常简单的脚本:

# If you are unsure of how to get quantstrat:
library(devtools)
install_github("braverock/quantstrat")

出于某种原因,这不会回应一个价值,但我不确定为什么。任何人都能理解为什么这不起作用吗?

非常感谢

1 个答案:

答案 0 :(得分:1)

没有回音的价值。 $commentID从未设置过任何内容:

$post = new Comment();
echo $post->get_commentID();

您可以调用其他方法来设置值:

$post = new Comment();
$post->set_commentID(); // here
echo $post->get_commentID();

其他选项包括在类本身中设置默认值,例如在构造函数中。