how to add variable in array element in php? -
code:
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 ) );
this not work. www_root . 'productimages' . ds . 'thum' . ds, , www_root . 'productimages' . ds . 'small' . ds
reason of error. doing wrong?
http://docs.php.net/language.oop5.properties says:
properties
[...]
they defined using 1 of keywords public, protected, or private, followed normal variable declaration. declaration may include initialization, but initialization must constant value--that is, must able evaluated @ compile time , must not depend on run-time information in order evaluated.
constant scalar expressions added in php 5.6.0.
therefore
<?php define('a_constant', '123'); class foo { public $bar = 'abc'.a_constant; }
works in php 5.6+ not before.
Comments
Post a Comment