Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

php coders please help with this syntax...


Recommended Posts

could some please describe to me what the syntax of these lines of code is actually doing??

$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';

Well, let me rephrase that...it is obviously loading a multi-dimensional array with some text...


...BUT $quote (which is first referenced in this snippet, so I am no idea what its supposed to hold except by looking at what data is being thrust into it) is a 4 dimensional array that allows not only integers for indexes but also strings??? Coming from a 20-year C/C++ background this syntax seems somewhat insane, but is this standard PHP??


What blows me away the most is that 'methods' is not referenced anywhere else in this checkout_shipping.php code (where this example lives), so you are not sure exactly what its purpose is or its scope! Is it a GLOBAL variable from some other module, or just a "tag" to help with code commenting?? You have some fairly random string of text used in a multi-dimensional array of unknown type (because of course PHP is very "anti"-type) and are supposed to quickly start adding features to this code.


I can see some of the advantages of PHP, but I'll tell you this sort of thing makes large projects much more difficult to get up to speed with then, say C or C++ with the stringent type-checking that is constantly going on.


Can some good PHPer out there point me to a site that discusses these sort of issues??

Edited by menriquez
Link to comment
Share on other sites

yea the keys (indices) in php can be integers or strings.




there are examples for other data types as well as md-arrays and how to use them.


Also each of the shipping modules assigns its class object with a global scope. See the constructor in includes\classes\shipping.php how it parses the shipping modules and uses the $GLOBALS to do that. Then you will see how the methods of each module can be utilized.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...