jbastarras Posted February 18, 2015 Share Posted February 18, 2015 Hello, I'm having problems with PHP 5.2.17 version installing a module. I get errors ( sintax error '[' ) with these lines $context = stream_context_create($cparams); $fp = fopen($url, 'rb', false, $context); if (!$fp) { $result = false; } else { $result = stream_get_contents($fp); } if(!$result) { $result = ['codigo' => 'ERROR', 'descripcion' => 'Error de conexion ', 'tipo' => 'KO]; } else { switch ($format) { case 'json': $result = json_decode($result, true); if ($result === null) { $result = ['codigo' => 'ERROR', 'descripcion' => 'Error de conexion, 'tipo' => 'KO']; } break; case 'xml': $result = simplexml_load_string($result, true); if ($result === null) { $result = ['codigo' => 'ERROR', 'descripcion' => 'Error de conexion', 'tipo' => 'KO']; } break; } } or public static function app($key) { return self::config('app')[$key]; } Is there any way to do this otherwise to be compatible with both versions ? With 5.3 no problem Thank You Regards Link to comment Share on other sites More sharing options...
fred-vinapresta Posted February 18, 2015 Share Posted February 18, 2015 Hi, the best way would be to upgrade your php version, can't the hoster do that? Anyway, try with that , replace your array ['key1' => value1, 'key2' => value2] by array('key1'=>value1,'key2'=>value2); Link to comment Share on other sites More sharing options...
jbastarras Posted February 19, 2015 Author Share Posted February 19, 2015 Thanks I can´t change the version of php . I solved first block of code but the second problem I don´t know solve public static function app($key) { return self::config('app')[$key]; } Thank you Regards Link to comment Share on other sites More sharing options...
bellini13 Posted February 19, 2015 Share Posted February 19, 2015 Then you should find a new host. PHP 5.2 is no longer supported and no longer receives updates. http://php.net/eol.php If your host will not upgrade, then find a new host. I realize that is not the answer to your question, but you are focused on the wrong thing. Anyway, what does the function 'config' do? And what does it return? return self::config('app')[$key]; Link to comment Share on other sites More sharing options...
jbastarras Posted February 19, 2015 Author Share Posted February 19, 2015 (edited) Thanks but change php version not depend on me app.php ?php return array( 'module_name' => 'module', 'cliente_api' => 'prestashop', 'url' => 'http://localhost:8080/url/ecommerce', ); I want return a array in the app.php file Thanks Regards Edited February 19, 2015 by jbastarras (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted February 19, 2015 Share Posted February 19, 2015 It is not clear what you are trying to do. the code you have provided is not even a function Link to comment Share on other sites More sharing options...
jbastarras Posted February 23, 2015 Author Share Posted February 23, 2015 I am calling an array of app.php file . this is app.php ?php return array( 'module_name' => 'module', 'cliente_api' => 'prestashop', 'url' => 'http://localhost:8080/url/ecommerce', ); And now I want to call the module property . I want return 'module' ( name of may module ) This is a util function that I use all of module of prestashop public static function app($key) { return self::config('app')[$key]; } But this sentence return self::config('app')[$key]; fail in Php version 5.2.7 Thanks Regards Link to comment Share on other sites More sharing options...
bellini13 Posted February 23, 2015 Share Posted February 23, 2015 And where is config defined? return self::config('app')[$key]; Link to comment Share on other sites More sharing options...
jbastarras Posted February 23, 2015 Author Share Posted February 23, 2015 Inside module module\config\app.php Link to comment Share on other sites More sharing options...
bellini13 Posted February 23, 2015 Share Posted February 23, 2015 and what does it do? and why not pass in the key to the config function? instead of doing this return self::config('app')[$key]; why not do this return self::config('app', $key); Link to comment Share on other sites More sharing options...
jbastarras Posted March 2, 2015 Author Share Posted March 2, 2015 Not working ( return nothing ) and It fails also with version 5.3 . With 5.4 works Parse error: syntax error, unexpected '[' in C:\develop\prestashop\modules\module\classes\Util.php on line 10 [PrestaShop] Fatal error in module Util:syntax error, unexpected '[' Thanks Regards Link to comment Share on other sites More sharing options...
bellini13 Posted March 2, 2015 Share Posted March 2, 2015 why not answer my question? instead of doing this return self::config('app')[$key]; why not do this return self::config('app', $key); Link to comment Share on other sites More sharing options...
jbastarras Posted March 12, 2015 Author Share Posted March 12, 2015 return self::config('app', $key); not working . The function return a empty value Thanks Regards Link to comment Share on other sites More sharing options...
bellini13 Posted March 12, 2015 Share Posted March 12, 2015 and what does your config function do? if you want help, you need to post all of your code. this back and worth is just getting annoying. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now