This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:web_development:named_arrays [2021/12/23 18:05] mag [Foreach] |
en:web_development:named_arrays [2023/08/16 09:33] (current) |
||
---|---|---|---|
Line 51: | Line 51: | ||
* The first line sets up the loop. It says 'run through this code for each item in the array < | * The first line sets up the loop. It says 'run through this code for each item in the array < | ||
* We can now refer to the name and the actual item by using the variables < | * We can now refer to the name and the actual item by using the variables < | ||
- | * < | + | * < |
* Try it now to be sure you understand it. | * Try it now to be sure you understand it. | ||
Line 72: | Line 72: | ||
==== Objects ==== | ==== Objects ==== | ||
+ | * Objects are an advanced data structure and we won't go into it too much here, but you'll need to understand a little bit to use the PHP database connection. | ||
+ | * An object is like a named array where you can access each element by name. | ||
+ | * But an object also has functions built into. Recall that in Javascript < | ||
+ | * Similarly, in PHP, an object can have both data and functions. For example, a database connection object can have information about the connection and also have functions to extract data. | ||
+ | * Whereas you access the information in an array using < | ||
+ | * To use an abstract example, we could create an object called $table. | ||
+ | * We could set the number of legs on the table as follows. | ||
+ | < | ||
+ | * We could also move the table to another location as follows. | ||
+ | < | ||
+ | * There is a whole school of programming based on objects (Object-oriented programming) and objects could be the subject of many classes, but this is all you need to know to use the database connection. | ||
+ | [[en: |