代码:
public $img_config = array('thum_img' => array(
'image_ratio_crop' => true,
'image_resize' => true,
'image_x' => 175,
'image_y' => 240
),
'small_img' => array(
'image_ratio_crop' => true,
'image_resize' => true,
'image_x' => 110,
'image_y' => 35
),
'parent_dir' => 'productImages',
'target_path' => array(
'thum_img' => WWW_ROOT . 'productImages' . DS . 'thum' . DS,
'small_img' => WWW_ROOT . 'productImages' . DS . 'small' . DS
)
);
这不起作用。WWW_ROOT . 'productImages' . DS . 'thum' . DS, and WWW_ROOT . 'productImages' . DS . 'small' . DS
是错误的原因。我做错了什么?
http://docs.php.net/language.oop5.properties说:
属性
[…]
它们是通过使用一个关键字public、protected或private来定义的,后跟一个普通变量声明。此声明可能包括一个初始化,但此初始化必须是一个常数值——也就是说,它必须能够在编译时进行求值,并且必须不依赖于运行时信息才能进行求值。
php 5.6.0中添加了常量标量表达式。
因此
<?php
define('A_CONSTANT', '123');
class Foo {
public $bar = 'abc'.A_CONSTANT;
}
可在php5.6+中工作,但以前没有。