Tuesday, November 5, 2019

Understanding Arrays in PHP

Understanding Arrays in PHP An array is a systemic arrangement of objects. Hum, what does this mean? Well in programming an array is a type of data structure. Each array can hold several pieces of information. It’s sort of like a variable in that it stores data, but not at all like a variable in that instead of storing one bit of information it can store many pieces of information. Let’s start with an example. Let’s say that you are storing information about people. You could have a variable that stored my name â€Å"Angela†. But in an array, you could store my name, my age, my height, my In this sample code, we will look at storing two bits of information at a time, the first being somebody’s name and the second being their favorite color. ?php $friend[0] Kevin; $friend[1] Bradley†; $friend[2] Alexa; $friend[3] Devin; $color[Kevin] â€Å"Teal†; $color[Bradley] â€Å"Red†; $color[Alexa] â€Å"Pink†; $color[Devin] â€Å"Red†; print My friends names are . $friend[0] . , . $friend[1] . , . $friend[2] . , and . $friend[3]; print p; print Alexa ‘s favorite color is . $color[Alexa] . .; ? In this example code, you can see that the friend array is sorted by number, and contains a list of friends. In the second array, color, instead of using numbers it uses strings to identify the different bits of information. The identifier used to retrieve data from the array is called it’s key. In our first example, the keys were integers 0, 1, 2, and 3. In our second example, the keys were strings. In both cases, we are able to access the data held in the array by using both the array’s name, and the key. Like variables, arrays always start with a dollar sign ($array) and they are case sensitive. They can not start with an underscore or a number, you must start them with a letter. So, to put it simply, an array is kind of like a variable with lots of little variables inside of it. But what exactly do you do with an array? And how is it useful to you as a PHP programmer? In practice, you will probably never create an array like the one in the example above. The most useful thing you can do with an array in PHP is to use it to hold information you get form somewhere else. Having your websites information stored in an MySQL database is not uncommon. When your website needs certain information it simply accesses your database, and wha-laa, on demand data. Let’s say you have a database of people who live in your city. You now want to search that database and print out records for anyone named â€Å"Tom†. How would you go about doing this? You would read through the database for people named Tom, and then pull their name and all the other information about them from the database, and place it in an array inside of your program. You are then able to cycle through this array, and print out the information or store it to use elsewhere in your program. On the surface, an array might not look that interesting to you, but when you do more programming and start storing more complex data structures you will find you are often writing them to arrays when they need to be used.

Saturday, November 2, 2019

Corporate Finance High School Essay Example | Topics and Well Written Essays - 1500 words

Corporate Finance High School - Essay Example That is, organizations need to be structured in such a way so the agent will expect that diligently serving the interests of his or her principals will also be in his or her own long-run best interests. In order to accomplish this, the principals need to be reasonably clever in setting up the initial rules of the game that are set in the employment contract , sufficiently vigilant in keeping track of their agents' quality of performance over time, and willing to bear at least some minimum level of "agency costs" in order to provide the necessary incentives There are many definitions for the term ethical investment, and what this term entails. Ritsie Lowry, maintainer of the GoodMoney site1 suggests that "In one sense, ethical investment is just like traditional investment. Ethical investors pursue the same economic goals as all investors: capital gains, higher income and/or preservation of capital for future needs. However, ethical investors want one additional thing. They don't want their investments going for thing that cause harm to the social or physical environments, and they do want their investments to support needed and life-supportive goods and services". From this certain definition we are able to realize that ethical investment is similar to the conventional investment, but differs to the fact that it needs one more requirement. Ethical Investors are very strict as far as the kind of business their money is going to fund. Many researches have proved that the ethical investors prefer to invest their money ethically although they know beforehand that the investment will not be as lucrative as a traditional investment. Russell Sparkes 2 in his book mentions "Repeated surveys (the last by Minitel in 1991) have shown that around 40% of the public want their money invested ethically. Interestingly enough, most of those in favor said that they would make ethical investments even if they knew that the returns would be lower than on conventional investments". Nevertheless there exist some facts which prove that ethical investment is quiet lucrative and in some cases more lucrative than the traditional investment. Weidner Investments3, point out four reasons, why the ethical investment is more profitable: 1) Management of the ethical company can focus on genuine growth without worrying about public reactions 2) Legal and hassle related costs are minimal 3) Brand loyalty is less expensive to maintain 4) Active ethical investors and consumers will give the firm free advertising again and again All these points seem quiet rational and representative of reality. We can assume that ethical