alin19 Posted February 10, 2009 Share Posted February 10, 2009 what should i change in php.ini to work bouth of the codes : echo $array['var']; echo $array[var]; Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/ Share on other sites More sharing options...
Mark Baker Posted February 10, 2009 Share Posted February 10, 2009 Nothing to change in php.ini echo $array['var']; should always work, as long as $array['var'] exists. echo $array[var]; will give you a warning unless you have a constant called var. If you don't, it will assume that you meant 'var' instead, and act accordingly; but it still generates the warning to let you know you've done something wrong. Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/#findComment-758826 Share on other sites More sharing options...
printf Posted February 10, 2009 Share Posted February 10, 2009 As Mark Baker pointed out, it better to fix the errors because disabling NOTICES can effect other problems especially if you have registered globals on. But if you must disable the notice so you can use [var] or ['var'], then... // in your script.. error_reporting ( E_ALL ^ E_NOTICE ); // or php.ini error_reporting = E_ALL ^ E_NOTICE Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/#findComment-758828 Share on other sites More sharing options...
coder_ Posted February 10, 2009 Share Posted February 10, 2009 in other words, if you wont to write a good code, in this case write $array['var']; Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/#findComment-758832 Share on other sites More sharing options...
PFMaBiSmAd Posted February 10, 2009 Share Posted February 10, 2009 Must be a homework question - http://www.phpfreaks.com/forums/index.php/topic,238023.0.html The answer is - you don't change anything in your php.ini to fix code that is using the second form (without quotes), you fix your code to use the correct syntax. Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/#findComment-758847 Share on other sites More sharing options...
Daniel0 Posted February 10, 2009 Share Posted February 10, 2009 I wish PHP would stop making it an implicit string. Then people would finally do it correctly. Quote Link to comment https://forums.phpfreaks.com/topic/144610-arrayvar-vs-arrayvar/#findComment-758925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.