1. Jiggy Jog S (final odd 1-5): $2.60 $2.10 $2.10
2. Pretender (final odd 1-1) $2.60 $2.10
3. Slay (final odd 3-1) $2.20
$2 Exacta (Jiggy Jog S / Pretender) Paid: $5.10
1. Stockade Seelster (final odd 4-5): $3.90 $2.20 $2.10
2. Moment Is Here (final odd 6-5) $2.30 $2.30
3. Gung Ho (final odd 18-1) $2.60
$2 Exacta (Stockade Seelster / Moment Is Here) Paid: $5.70
Remember that all other brokerage services charge you when you open your trade and also charge you when you close out your position. That's $10 for just one round trip--a $5 for opening position and a $5 for closing position. That's a lot of $5(s) and $10(s) to waste.
Please check the following out:
tastyworks.comAnother very good brokerage house that has zero commissions, zero options contract fees, zero deposit minimum. Please check the following out:
Webull.COM There are plenty of other brokerage services that have no minimum -- or if they do, it is very little minimum and the majority of them have a minimum of $25. Some brokers have no minimum but require their clients to keep accounts active by mean of trading. So look around.Article Date: August 9, 2014
By Paul S. Tuon
The total of all those shares (or in the previous example, 400,000,000) is called shares outstanding. All those shares outstanding is called a stock, hence answering the question posed earlier 'what is a stock?'
Notice that a company can have many stocks: common stock, preferred stock and warrants, and each of the three types of stocks can contain classes of their own, such as common stock class A, B, C, etc., Preferred stock class A, B, C, etc.; and each class in those three types of stocks is also called a stock.
Now the answer to the question: 'what is a stock?' is now much clearer.
Different classes of a stock contain different rights and privileges, with the highest rights and privileges given to the highest alphabet order. For example, class A shares have higher rights and privileges than class B, class B shares have higher rights and privileges than class C, class C shares have higher rights and privileges than class D, and so forth.Of the three types of stocks, common stock shares have the least rights and privileges and preferred stock shares have the highest rights and privileges and its classes shares generally have preferrential treatment over all common stock classes shares and also have preferrential treatment over all warrant shares of a stock as well. warrant shares generally have rights and privileges somewhere between common stock shares and preferred stock shares.
A share of a stock whether a common stock, a class A, B, or C, or preferred class A, B, or C, or warrants, represents a part-ownership in the company. A publicly traded company is owned by its shareholders, including the original owner(s) -- often thousands of people and institutions -- each owning a fraction of the whole company.A newly formed company usually requires a "bylaw" written by the founders of the company. The bylaw states the rights and duties of the company, including ownership interest. At a very minimum, the bylaw should issue certificates of stock ownership to the shareholders involved, including the founders and early investors at the inception.
Here is what a typical certificate of ownership looks like:
Certificate Number: 1000 This certifies that Mary Q. Public is the owner and registered holder of twenty thousand (20,000) shares of ABC Corporation, transferable only on the books of the corporation by the holder hereof in person or by duly authorized attorney upon surrender of this certificate properly endorsed. IN WITNESS WHEREOF, the said corporation has caused this certificate to be signed by its duly authorized officers of the corporation this 2nd day of October, 2018. ABC Corporation by president: ___________________________ John J. Doe |
shareholders dilution.
shareholders dilution
: it dilutes existing shareholders' value because there are more shares outstanding and perhaps there are more shareholders in the company. The more shares the company is selling the more dilute value for existing shareholders.Strike | Symbol | Last | Chg % | Bid | Ask | Volume | Open Interest |
$15.00 | T100918C00015000 | 7.45 | 0.23 | 7.40 | 7.50 | 45 | 175 |
$25.00 | T100918C00025000 | 3.45 | 0.04 | 3.40 | 3.50 | 106 | 694 |
Call Options Quotes |
For AT & T, Inc (Symbol: T): 07-30-2010: $25.94 |
Expire at close on Friday September 17, 2010 |
Strike | Symbol | Last | Chg % | Bid | Ask | Volume | Open Interest |
$23.00 | T100918C00023000 | 2.94 | 0.23 | 3.00 | 3.05 | 45 | 175 |
$24.00 | T100918C00024000 | 2.15 | 0.04 | 2.10 | 2.13 | 106 | 694 |
$25.00 | T100918C00025000 | 1.31 | 0.05 | 1.27 | 1.28 | 138 | 2,924 |
$26.00 | T100918C00026000 | 0.63 | 0.00 | 0.60 | 0.61 | 322 | 11,331 |
$27.00 | T100918C00024000 | 0.21 | 0.02 | 0.19 | 0.21 | 466 | 3,637 |
$28.00 | T100918C00024000 | 0.06 | 0.01 | 0.04 | 0.06 | 120 | 808 |
$29.00 | T100918C00029000 | 0.02 | 0.00 | N/A | 0.02 | 10 | 20 |
$30.00 | T100918C00024000 | 2.15 | 0.04 | 2.10 | 2.13 | 106 | 694 |
Put Options Chain Quotes |
For AT & T, Inc (Symbol: T): 07-30-2010: Price $25.94 |
Expire at close on Friday September 17, 2010 |
Strike | Symbol | Last | Chg % | Bid | Ask | Volume | Open Interest |
$23.00 | T100918P00023000 | 0.05 | 0.00 | 0.09 | 0.11 | 6 | 1,651 |
$24.00 | T100918P00024000 | 0.15 | 0.01 | 0.16 | 0.18 | 131 | 1,025 |
$25.00 | T100918P00025000 | 0.31 | 0.00 | 0.32 | 0.34 | 76 | 3,194 |
$26.00 | T100918P00026000 | 0.63 | 0.03 | 0.65 | 0.67 | 283 | 1,634 |
$27.00 | T100918P00027000 | 1.24 | 0.02 | 1.24 | 1.27 | 273 | 1,774 |
$28.00 | T100918P00028000 | 2.05 | 0.03 | 2.09 | 2.11 | 78 | 439 |
$29.00 | T100918P00029000 | 3.15 | 0.15 | 3.05 | 3.10 | 89 | 18 |
$30.00 | T100918P00030000 | 4.15 | 0.15 | 3.95 | 4.10 | 124 | 1 |
In options lingo, selling a "covered call" is called "writing a covered call." There are two steps for this process:
Step 1: Buy the stock for the purpose of selling the right to own the stock to someone else.
Step 2: Sell a call option or writing a call option. Writing a covered call option means that you're giving other investors the "right to buy" your 100 shares of your stock that you'd bought and currently are holding them.
The call option you sold requires you to deliver your 100 shares of the stock if the option is exercised. That can happen anytime between the time you sold and the expiration date of the option. Remember that you need to hold your stock until the option expires.
As of this writing (March 26, 2018), the call option you want to sell is the Citygroup stock quoted for April 27, 2018 (expire in one month) with a strike price of $67.00 for a premium of $3.50 per share. OK, you bought a Citygroup stock at $67 a share and turn around and sell a covered call for the same amount as you bought them.Update: July 21, 2021. Nivdia stock: $194/share. Nvidia Corp. today begins trading on a post-4-for-1 stock split. From now on the stock base point per share to gauge is $194 (and not $819) per share. Update: July 2, 2021. Nivdia stock: $819/share. Update: May 21, 2021. Nivdia stock: $598/share. Nvidia Corp. today announced it would split its shares 4-for-1 in an effort to make them more accessible to investors and employees. You can think of a stock split as exchanging a $1 bill for four quarters. The total value is the same; it's just divided into more pieces; or for a reverse split, it's just combines more shares into smaller shares, giving you less shares but not less amount of money that you get. Stock splits don't change the fundamental value of a business. So for a 4-for-1 split is in many ways like exchanging a $1 bill for four quarters. In the end, you get the same amount of money for your stock holding. The split, in the form of a stock dividend, is subject to shareholder approval at the Santa Clara, California-based company's annual meeting on June 3, 2021, Nvidia said in a statement today Friday. The move, if approved, would increase the common stock to 4 billion shares. The shares jumped 3.1% as trading got underway in New York earlier today Friday. Currently Nvidia has about 622.4 million shares outstanding, valuing the company at $363.8 billion, based on Thursday's closing share price of $584.50. The stock has gained 12% so far this year (2021). If shareholders approve the plan, each Nvidia stockholder of record on June 21 will receive a dividend of three additional shares of common stock for every share held, to be distributed after the close of trading on July 19, 2021. Trading is expected to begin on a stock split-adjusted basis on July 20, 2021. Update: October 27, 2020. Nivdia stock: $536/share. The stock is now at $536/share, surpassing my 5-year target of $320 per share. Better yet, this company is growing rapidly in a 'breakneck' speed through in-house inovations and outside acquistions. So the future is very bright. The management is very smart in using their 'skyrocket' high stock price to buy these valuable companies without denting their cash on-hand. That's what you can do when your company's stock is as high as NVIDIA is - it gives you leverage and power to do things that otherwise would not be possible.
Nvidia reminds me of Amazon just a few years ago when Amazon stock was already trading around $500 per share and the stock was moving up steadily ever since [February 26, 2016 at $555 per share; October 27, 2017 at $1,100 per share; May 11, 2018 at $1,603 per share; November 11, 2019 at $1739 per share; March 27, 2020 at $1,900 per share; May 29, 2020 at $2442 per share; September 4, 2020 at $3294 per share; June 22, 2021 at $3505 per share].
Let me clarify my view on this comparison: Nvidia is not Amazon nor will it perform like Amazon stock in the future. It will never be anything near what Amazon has done -- no stock is nor will be. However, the strategy that Nvidia employs recently resemblances the strategy that Amazon employed leading up to their current high performances of its stock.
The purchase of ARM is a very smart move by Nvidia's management and it will do a lot of good for the future of this company. Will its stock performs like Amazon's stock in the future? We'll see! And time will tell!
Here is the synopsis from the press release:
Unites NVIDIA's leadership in artificial intelligence with Arm's vast computing ecosystem to drive innovation for all customers
NVIDIA will expand Arm's R&D presence in Cambridge, UK, by establishing a world-class AI research and education center, and building an Arm/NVIDIA-powered AI supercomputer for groundbreaking research
NVIDIA will continue Arm's open-licensing model and customer neutrality and expand Arm's IP licensing portfolio with NVIDIA technology
Immediately accretive to NVIDIA's non-GAAP gross margin and EPS
Consideration of $40 billion to be met through a combination of NVIDIA shares and cash
Please see
NVIDIA to Acquire Arm for $40 Billion, Creating World's Premier Computing Company for the Age of AIHere is my definition of "dollar cost average":
"Stocks rarely go up in a straight line."
Just remember that definition when you think of a dollar cost average.
Because of the nature of stocks, which rarely go up in a straight line, it makes a great strategy for a long term investment.
I'm not the only one who believe that this stock is going to go up in five years. Here is what WallStreet analysts are saying about Nvidia:Goldman said it remains "Buy-rated on the stock as our view that Nvidia has access to one of the best growth opportunity sets in Semis and that it has a sustainable competitive lead within remains unchanged."
"The stock will likely not bounce back right away, given the severity of the miss," Morgan Stanley said.
Wells Fargo Analyst: Concerns (and now frustration) over a significant gaming channel inventory burn-off have materialized ... While we can appreciate that NVIDIA's weak F4Q19 outlook is impacted by a 1-2 quarter work-down of Pascal mid-range gaming card inventory in the channel ($600M; assuming no sell-in in F4Q19 as crypto-related dynamics flush through the channel), couple with a seasonal decline in game console builds, we think investors will be frustrated by NVIDIA's comments exiting F2Q19 that: "...we [NVIDIA] see inventory at the lower-ends of our stack...inventory is well positioned for back-to-school and building season that's coming up on F3Q19..." Bottom Line: Well, even if we model a strong double-digit growth in DCG next year, we think there is a high likelihood that NVIDIA will not grow next year. We are modeling for as such. The large shortfall in guidance due to a bloated channel due to crypto-currency is in sharp contrast to the comments around channel inventory from the company at the last earnings call. Our estimates and target price are going lower. We remain Market Perform rated. We are Buyers on weakness.
SunTrust Analyst: The surprisingly weak Q4 guide appears temporary. NVDA guided Q4 20% below consensus revs as the company halts 1/3 of gaming segment sales to flush channel inventory built during the crypto enthusiasm in 1H18. This badly damages near-term revenue and profits, but Datacenter, Pro-Viz, and Automotive results support our structural growth view. Gaming resets our 2019 & 2020 EPS to $7.33 & $8.70 (from $8.18 & $9.59). PT goes to $237 (from $316) based on 30x (17x discount to rapid-growth tech peers) our CY20 EPS, discounted back 1 year. Buy.
RBC Analyst: Going forward, we think the focus will now shift to Data Center as gaming expectations are now reset due to crypto currencies and a product transition (Turing) which will unlikely ramp until around the Jul-qtr time frame. Net Net: we lower our price target due to the lower than expected results (PT to $260 from $310). Positively, gaming and Pro Visualization will likely be up q/q in January helping gross margins and offsetting the material gaming weakness.
Update: July 2, 2021. AbbVie stock: $115/share.
3. Texas Pacific Land Trust (TPL), stock price on July 31, 2018: $740.00 ===> Texas Pacific Land Trust was created in 1888 as a result of a bankruptcy of the Texas and Pacific Railway Company. A company, or more specifically a trust, that is trying to go out of business and ceased to exist.
Why would I or anyone want to invest in a company that is trying to go out of business?
As they say: "... the devil is in the detail."
What exactly is in the detail? Read on.
My 5-year target: $2800 a share -- a 3 1/2 times current price of $740.00 per share.
Update: July 2, 2021. Texas Pacific Land Trust stock: $1593/share. It's Texas Pacific Land Corporation now.
Note (about the WARNING above) that TPL's annual report filed on Form 10-K and Form 10-Q filed in 2020 stated that Texas Pacific Land Trust (TPL) will become Texas Pacific Land Corporation (TPL) on January 1, 2021 -- as it will be converted from a trust to a real corporation called the Texas Pacific Land Corporation.
The trust will cease to exist and a new era begins (on January 1, 2021) as a real corporation called the Texas Pacific Land Corporation from January 1, 2021 and onward.
Payment Type | Declared Date | Payable Date | Amount |
Annual Regular Dividend | February 25, 2016 | March 16, 2016 | $.31 |
Annual Regular Dividend | February 21, 2017 | March 9, 2017 | $.35 |
One-time Special Dividend | February 21, 2017 | March 9, 2017 | $1.00 |
Annual Regular Dividend | February 21, 2018 | March 16, 2018 | $1.05 |
One-time Special Dividend | February 21, 2018 | March 16, 2018 | $3.00 |
Annual Regular Dividend | February 25, 2019 | March 15, 2019 | $1.75 |
One-time Special Dividend | February 25, 2019 | March 15, 2019 | $4.25 |
Annual Regular Dividend | February 24, 2020 | March 16, 2020 | $16.00 |
Quarterly Regular Dividend | March 08, 2021 | March 15, 2021 | $2.75 (or $11 annually) |
Quarterly Regular Dividend | June 08, 2021 | June 15, 2021 | $2.75 (or $11 annually) |
Quarterly Regular Dividend | September 10, 2021 | September 15, 2021 | $2.75 (or $11 annually) |
Quarterly Regular Dividend | December 07, 2021 | December 15, 2021 | $2.75 (or $11 annually) |
As of January 1, 2021, it's the seventeenth consecutive year that the annual dividend has been increased.
Note that Texas Pacific Land Trust (TPL) has become Texas Pacific Land Corporation (TPL) -- it's no longer a trust, which has been converted into a real corporation called the Texas Pacific Land Corporation.
Note (about the WARNING above) that TPL's annual report filed on Form 10-K and Form 10-Q filed in 2020 stated that Texas Pacific Land Trust (TPL) will become Texas Pacific Land Corporation (TPL) on January 1, 2021 -- as it will be converted from a trust to a real corporation called the Texas Pacific Land Corporation.
The trust will cease to exist and a new era begins (on January 1, 2021) as a real corporation called the Texas Pacific Land Corporation from January 1, 2021 and onward.
This means that the shares outstanding will decrease over time, little by little, while the stream of income just keep coming, driving the stock price higher and higher and higher, hence lands this stock in the third ranking of my pick.Note (about the WARNING above) that TPL's annual report filed on Form 10-K and Form 10-Q filed in 2020 stated that Texas Pacific Land Trust (TPL) will become Texas Pacific Land Corporation (TPL) on January 1, 2021 -- as it will be converted from a trust to a real corporation called the Texas Pacific Land Corporation.
The trust will cease to exist and a new era begins (on January 1, 2021) as a real corporation called the Texas Pacific Land Corporation from January 1, 2021 and onward.
You're among the last lot of shares to be bought out by the trust to cease to exist. At that time, the trust would still have some pieces of valuable land to get rid of and it tries to get the highest bid for the lands. Once the pieces of land are sold, the proceeds are used to buy the remaining lot of shares to close out the trust.Note (about the WARNING above) that TPL's annual report filed on Form 10-K and Form 10-Q filed in 2020 stated that Texas Pacific Land Trust (TPL) will become Texas Pacific Land Corporation (TPL) on January 1, 2021 -- as it will be converted from a trust to a real corporation called the Texas Pacific Land Corporation.
The trust will cease to exist and a new era begins (on January 1, 2021) as a real corporation called the Texas Pacific Land Corporation from January 1, 2021 and onward.
Update: July 2, 2021. Micron Technology stock: $80/share.
A foreign reserve is the foreign currency that a country has in its possession or in its bank vault. For example, China has trillions of U.S. dollars stored in its bank vault. Actually, most of the trillions of U.S. dollars China has on its book are in the form of U.S. Treasury Securities (which it can be turned into U.S. dollars at any time).
That is China's foreign reserve. It's a foreign money it has in its possession or in its bank vault.
Many other countries also hold currencies of other countries as well, particularly the U.S. dollars, as their foreign reserve.
So a foreign reserve is a foreign money a particular country has in its possession or in its bank vault.
Remember that a country typically has its own currency, e.g., the United States has the dollar as its own currency, Great Britain has its own currency called the Pound, China has its own currency called the Yuan, Japan has its own currency called the Yen, the 12 European countries: France, Germany, Italy, etc., have their own currency called the Euro dollar.
For the most part, each currency can be used inside its own country only; for example, the Chinese Yuan can be used only inside China, and likewise, the European Euro dollar can be used only inside the 12 European countries and nowhere else.
When people travel to a foreign country, they have to exchange their own country's currency with of that foreign country's currency.
For example, if you go to China or any other country for that matter, once you arrived at the country's airport you need to exchange your U.S. dollar with that country's currency so that you can use it to buy things while you're in that country. Another example, when you go to France (or any one of the 12 European countries that carry the Euro dollar), you need to exchange your U.S. dollar with the Euro dollar so that you can use it to buy things in those countries.
Likewise, when businesses invest or trade with a foreign country, they have to exchange their own country's currency with of that foreign country's currency.
For example, when Walmart Corporation and other U.S. companies buy Chinese products to sell in their stores in the U.S., they need to exchange their U.S. dollar with the Chinese Yuan so that they can use the Chinese Yuan to buy those Chinese products because the Chinese government barred the use of foreign currencies inside China.
Most countries do this as well, e.g., you can't use the Euro dollar to buy things in the United States either.
When U.S. companies buy products from Chinese companies, Chinese companies take those U.S. dollars and deposit them in their bank accounts in Chinese banks or more specifically in Chinese cenral bank, which is controlled by the Chinese govenment.
And those U.S. dollars, in turn, get converted by the Chinese central bank into Chinese Yuans, giving Chinese companies their actual Chinese currency -- and not in U.S. currency.
Well, most likely U.S. companies need to convert U.S. dollars into Chinese Yuans first and then buy Chinese products using Chinese Yuans instead.
Anyhow, the effect is still the same: China has lots and lots of U.S dollars -- trillions of it!
Japan also has lots and lots of U.S dollars -- trillions of it -- due to its longstanding trading surpluses with the United States for decades and decades.
Among of all the countries of the world, Asian countries have the world's largest holdings of U.S. dollar reserves (in the form of foreign reserve) -- a legacy of the 1997 Asian financial crisis where policymakers fretted about dollar shortages and free-falling local currencies.
In reserve holdings (as of January 1, 2022), China towers above them all with a cash pile above $3 trillion but peer countries in the region have also been formidable accumulators, predominantly in the US dollar. They include Japan ($1.4 trillion), Singapore ($426 billion), India ($604 billion), Taiwan ($550 billion), and South Korea ($457.8 billion).
Like other big economy countries, including the U.S., the Chinese goverment can print money out of thin air without fearing of inflation or de-value(ing) their currency by printing money out of thin air whenever they want.
So to convert the U.S. dollars into the Chinese Yuans, the Chinese goverment can print more Chinese Yuans and credit Chinese companies in exchange for their U.S. dollars.
In effect, China has lots and lots of U.S dollars -- trillions of it!
The United States is notorious in the business of money printing, particularly in the 1929 Great Depression, the Federal-Aid Highway Act of 1956 (which was used to build The Interstate Highway System), the 2008 Financial Crisis (commonly known as The Great Recession), and most recently, the COVID-19 Pandemic Crisis of 2020 (and the aftermath of the COVID-19 Pandemic Crisis).
From January 2020 to June 2022, the United States alone printed $7 trillion and we are not done printing money yet (as of June 2022).
So as a result, both the U.S. and China have lots of money supply floating around (particularly the U.S.), with the U.S. Federal Reserve printing money supply to buy bonds sold by U.S. companies; while China has trillions of U.S. dollars (and other country's currencies as well) on its book because of the trade surpluses with other countries, particularly the United State.
All of these events (the money printing and exchanging of currencies) create a system of foreign reserve.
This system of foreign reserve, particularly, the exchanging of currencies is called the foreign exchange market.
A foreign exchange is a place where you can exchange your currencies for other currencies. It is like a stock exchange but instead of buy stocks, you buy other currencies using your own country's currency to buy other countries' currencies.
If you travel to other countries, you exchange your U.S. dollars using the foreign exchange market, which physically handles the exchange of the currencies.
Trades are the main source of the foreign exchange market (i.e., Walmart buying Chinese goods), causing each country's currency to fluctuate (or rise/fall in value) according to the supply and demand of the currency.
For example, the U.S. dollar is typically in high demand by traders all over the world and therefore it is more valuable than other currencies.
Keep the supply/demand principle in mind when you deal with the foreign exchange market, because it is based on the supply and demand of the currencies involved in the trade or exchange.
This trading of currencies in the foreign exchange market is where countries are so worried/abcessed with the concept of foreign reserve--they have to!. Their economy depends on it!
The answer to that question may surprise you and may even put you on edge if you're from a country that has low foreign reserve.
Two examples that come to mind is in 1992 when George Soros broke the Bank of England and another occurred in 1997 during the Asian financial crisis, particularly in Thailand after the Thai baht plunged in value.
Now we're on to the description of the foreign reserve concept in depth.
I'm little lazy, so I'm going to refer you to some excellent tutorials on the Web, which can explain better than I can.
As you watch the following videos, keep the trading of currencies in the foreign exchange market in mind because it is all about trading of currencies.
Also, don't forget to keep the supply/demand principle in mind as well.
To understand the concept of foreign reserve in depth, you have to at least finished watching the third video in the list below. The first two videos are just introductions to warm you up for the concept of the foreign reserve. Here are the video tutorials:
A SPAC (Special Purpose Acquisition Company), also known as a "blank-check" company, is a publicly listed company with no operations that raises money from investors via an IPO for acquisitions.
SPACs raise funds in an IPO to acquire a private company, which then becomes public as a result of the merger.
In other words, SPAC firms raise capital through an initial public offering with the intention of using the cash to acquire a firm and take the merged entity public.
A SPAC has no commercial operations, but exists solely to raise money by listing on the stock exchange, with the hope of finding and buying a profitable and fast-growing company to acquire. After the SPAC lists, it has a set time period in which to buy a target private company.
Typically, when you start a company you have some sort of products or services to offer to your consumers or clients. The normal process is that you would file a registration to begin the start of your company to begin the process of the "on going" business activities.
Once you're approved of the application, then you can begin the process of the "on going" business activities, such as building/creating products or services.
Most companies start out at its inception as a private company and later after the company has gained a foothold in the business world or be well-known and well-established in the business world as a well-respected company then it might want to go public in the form of an IPO.
In a SPAC, you file the registration to go public [the same way a well-established company does] as if you had gained a foothold or be well-known and well-established company already, and having some products or services to offer to your customers or clients. But in fact, you don't! No products or services! None! Just a blank-check company applying to list on the exchange for the public to own some shares.
Since the prospect or promise of buying a very good and profitable company to merge with [this blank-check company] is so enticing, many big pockets investors pore their abundance of money on the blank-check company hoping to get rich quick. And a lot of them have gotten rich, very rich, in fact!
Never mind that, you have a newly registered publicly traded (IPO) company that contains/has nothing - and never mind that this "blank-check" company only words of assurance is the promise of looking to acquire a good and profitable private company to merge with. Never mind all that -- big and small investors alike jump at the chance of making quick bucks.
Once it is registered as a SPAC and listed on the exchange as a publicly traded IPO company, you can go out and raise funds from investors and then use those funds to acquire a private company, and merging the acquired company with the blank-check company to form the combine (two) companies as one publicly traded company.
In the two years (of 2019 and 2020) we have seen market favorites including Virgin Galactic, DraftKings, and Nikola go public through such deals.
Blank-check IPOs exploded in 2020 as firms looked to take advantage of a surge in participation from retail investors and hopes for an economic recovery. More than $74 billion has been raised across 218 SPAC debuts in 2020, according to data from SPACInsider.com. That compares to just $13.6 billion raised across 59 deals in 2019.
To answer that question, let's go a little deeper into the detail of SPAC.
Here is an article that appeared on March 30, 2021 by POLITICO. We'll come back to my SPAC details after the article.
The shell companies (or holding companies or companies containing nothing -- or SPACs) that many private firms use to go public on the country's stock exchanges have been all the rage on Wall Street for more than a year (specifically 2019 and 2020). Now, just as their explosive growth shows signs of waning, they are coming under scrutiny from lawmakers and regulators.
Special purpose acquisition companies, or SPACs, which have no business operations and whose only purpose is to acquire a private company to then list on an exchange, have become so popular that they have outstripped traditional initial public offerings. The attraction of these so-called blank check companies, which have been backed by everyone from Shaquille O'Neal and A-Rod to Serena Williams? They get to bypass the costly IPO process, where companies must undergo vetting by the Securities and Exchange Commission before they can sell stock.
Now, lawmakers and consumer advocates are increasingly raising alarms about the risks facing unwitting investors, particularly retail buyers who might not be able to spot a bad deal on their own. And the SEC, which has been pressed by investor advocates for months to take steps to protect investors, is moving in.
"You shouldn't be able to use a SPAC to evade the disclosures and liabilities inherent upon taking a company public," said Rep. Brad Sherman (D-Calif.), chair of the House Financial Services subcommittee that oversees capital markets and investor protection.
Sherman said he thinks "a chunk" of companies are using the process to do just that, a concern shared by other Democrats on the committee, including Rep. Bill Foster of Illinois.
The SEC is looking into potentially illegal activity related to SPACs, according to people with knowledge of the inquiry. The probe was earlier reported by Reuters, which cited letters from the SEC to banks and other underwriters asking about their SPACs activity related to these offerings.
A banker familiar with the situation confirmed to POLITICO (the author of this article) that the SEC had sent a letter to the bank. Another banker said their company was aware that letters were going out on SPACs and that a probe is taking place.
The SEC declined to comment. But the agency this month issued a statement calling on investors to ignore celebrity endorsements of these vehicles. That came after earlier warnings from the regulator, including an investor bulletin in December -- "What you need to know about SPACs."
But just as policymakers and the SEC move to investigate, the performance of these companies appears to be faltering, according to data tracking their performance on the New York Stock Exchange and Nasdaq.
Data on SPAC performance 30 days out from a deal to take a private company public show the companies are performing worse on average in 2021 compared to 2020. While investors continue to show keen interest in buying stock in these SPAC shells before a deal, the declining performance suggests that finding a good deal to take a private firm public could be getting more difficult.
That could be a problem given all the new companies that are out there looking for deals.
Less than three months into 2021, SPAC IPO activity has already surpassed all of 2020, the year that the investment vehicles took up roughly half the market for new public company listings, in terms of deals and dollars raised. By comparison, the previous peak was 14 percent of the market in 2007, according to research firm SPAC Analytics.
Behind the surge is the prospect of a good deal for those who get in early, usually large, institutional investors. SPACs generally list on public markets with the proviso that they must acquire a private company in two or three years with the help of a sponsor who collects fees for a successful deal. That's when it tends to draw lots of small investors. If the SPAC fails to bring a private company public, it must return the money to investors, making the potentially lucrative investment appear relatively low risk.
But advocates fear many of these newly established companies will be under pressure to strike a bad deal instead of none at all, so early investors get a big return, sponsors get their fees and then retail investors take the loss when share prices plummet.
"Now all of a sudden, you own a garbage company," said Andrew Park, senior policy analyst at Americans for Financial Reform, a progressive investor advocacy group that has been warning policymakers for months about the dangers of SPACs.
Combined with growing animosity - particularly from private equity - toward the rigors of the traditional public offering process, interest in the companies soared along with the rising stock market. That has fed concern that there's a bubble ready to pop in SPACs.
"One of the clear dangers here is that there are going to be too many SPACs, chasing too few merger targets, that we're going to see some truly bad deals struck," said Foster, the Illinois Democrat. "This boom will just cause them to scrape the mud off the bottom of the of the pool."
Companies consult with the SEC when putting together the proxy and registration statements to take the private company public, and the agency can comment on their drafts. If there are enough shareholder votes to approve the acquisition, a financial disclosure to the SEC is then required of the combined entity. But during the initial listing process, a SPAC has little to offer except the promise of big future plans. That's a major reason why it has been so easy for them to crop up on public exchanges.
From January to mid-March (2021), there were 264 SPAC offerings on the Nasdaq and the NYSE raising $76.8 billion, according to a POLITICO analysis of listing data for the nation's two largest exchanges. That eclipsed traditional IPOs, which had just 74 deals and raised $30.1 billion over the same time period.
"The SEC's been warning investors now for months about the risks of SPACs, but that hasn't made a dent," said Tyler Gellasch, executive director of investor advocacy group Healthy Markets Association. "I expect the SEC and Congress are going to try to pop the speculative bubble soon, and a quick way to do that would be to restore some basic liability on those involved in the deals."
Proponents of SPACs say the transactions offer retail investors the chance to see bigger returns that might otherwise be reserved for the private market. They also view the boom in public offerings as positive for the market, regardless of whether companies fail, because it means more businesses are going public and providing financial disclosure to the SEC.
Those supporters include U.S. climate envoy John Kerry, who earlier in March said the investment vehicles are valuable because they could help finance green energy companies - a remark that drew a sharp rebuke from AFR.
"They provide spectacular windfalls for insiders while performing very poorly for most investors. They're not the solution to the climate crisis," AFR said in a tweet directed at Kerry.
Republican SEC Commissioner Hester Peirce has warned against regulating the new offerings too quickly. Doing so could reduce the cost-effectiveness of SPACs, she said this month during a meeting of the SEC's Investor Advisory Committee.
"Let's certainly look at what's going on, and try to get our arms around what's going on. The 'why now' questions I think are good questions to ask," Peirce said in an interview. But "we need to appreciate the potential for SPACs."
AFR and the Consumer Federation of America want policy changes that would require more disclosure and ensure legal protections for investors. The groups also say the SEC should conduct more research into what kinds of investors bear the most losses when these companies fail.
Carson Block runs a hedge fund that has bet against companies going public through SPACs, citing research on flimsy company fundamentals. But his warnings have been met with resentment from retail investors.
"This is clearly a situation in which unsophisticated retail is being preyed upon," Block said. "It's because there's euphoria, it's because the markets are being artificially stimulated, and I have seen this movie before, most closely in the late '90s to 2000s Internet bubble. The cure for it is to learn hard lessons."
John Jenkins, a veteran corporate lawyer, said regardless of what regulators do, the boom reflected a fundamental problem in the market.
"You can hammer on the disclosure side, you can hammer on making sure that the conflicts of interest are out there and laid out, but these things are prospering because there's kind of something wrong with the IPO process in general," he said.
But Sherman said the demand is a sign that regulators need to focus on the issue more.
Many companies "don't like the process of going public," the California lawmaker said. "If we can protect investors and make it easier to go public, that's what we should do. But, on the other hand, you don't need a backdoor that evades all of our efforts to protect investors."
[END OF POLITICO ARTICLE]
NOW ONTO MY SPAC IN-DEPTH DETAILS
Remember when you played card games with your brother, or sister, or cousin? Or maybe your son or daughter?
At some point they would have to use the bathroom, or get a drink of water, and bam! When no one was looking, you had your chance to stack the deck for the next round.
That's 4 aces or a royal flush in five card hold'em. Of course I could never keep a straight face afterward.
Several new SPACs have stacked the deck for their "founders" and warrant holders. And they're not joking around and always keeping a straight face before, during, and afterward while at the same time laughing all the way to the bank.
SPACs (or Special Purpose Acquisition Companies) (also known as Blank Check Companies) organize as if they were part of the fashion industry.
Nowaday (particularly 2021), you couldn't read a business article without coming across SPAC mania. SPACs have been all the rage on Wall Street for more than a year now (specifically 2019, 2020, and into 2021).
Someone comes up with the latest hot color to wear, or style of shoe, and then you see it everywhere.
SPACS are no different. Some underwriter, or attorney, will come up with a tweek to make the structure different.
"We're going to do one-half warrant per unit, in order to minimize dilution," etc., etc., etc.
Then every SPAC after that does one-half warrant per unit - and everybody jumps on the "copycat" bandwagon and everything is catching on like wildfire. As long as the rules are followed for the overall structure, nobody really cares.
The offering to sell SPAC units to the public is typically advertised in a press release that looks like the following:
NEW YORK, Aug. 24, 2020 /PRNewswire/ -- Far Point Acquisition Corporation (NYSE: FPAC.UN) a special purpose
acquisition company, announced today that it is offering 23,000,000 units (including 3,000,000 units granted
to underwriters' over-allotment option in full) at $10.00 per unit, resulting in gross proceeds of $230,000,000.
The units will begin trading on the New York Stock Exchange Capital Market ("NYSE") under the symbol
"FPAC.UN" on November 13, 2019.
Each unit consists of one share of Class A common stock and one-third of one warrant.
Each whole warrant is exercisable to purchase one share of Class A common stock at a price of $11.50 per share.
Only whole warrants are exercisable. Once the securities comprising the units begin separate trading,
the Class A common stock and warrants are expected to be listed on the NYSE under the symbols "FPAC" and "FPAC.WS,"
respectively.
What the Newswire press release is saying is that this SPAC is announcing to the general public
that it is selling "Units" of the SPAC to anyone interested in buying the Units.
Each unit consists of one share of Class A common stock and one-third of one warrant -- meaning,
you buy one Unit at a price of $11.50, you get one share of Class A common stock and
one-third of one warrant.
So you have to buy at least three Units to make your warrant worth one whole warrant,
which can be exchange for one share of Class A common stock.
Just to be clear, I'm speaking from a trading perspective. I have not done an exhaustive study of SPAC structures and how they benefit shareholders / investors, etc.
Bottom line, once a fashion is established in SPAC IPOs it tends to stick. But for how long will the fashion can sustain its attractiveness? According to the POLITICO article above, a bubble looms on the horizon.
When I think of a "founder" I think of the guy or gal who is working 18 hours a day to get a business off the ground. Basically someone who has put in some sweat equity - someone who has some ideas to make things happen.
But I'll turn it over to the experts. This is what Forbes has to say:
Founder is a label with some amount of prestige. It carries connotations of creativity and innovation, determination, native intelligence, and a sense of fearlessness. Founders create something from nothing.
And they go on to add:
Strictly speaking, in business the founders are the people who establish the company -- that is, they take on the risk and reward of creating something from nothing.
You may ask, if we're talking SPACs, a pool of money raised from investors to buy an existing business, then why the talk of founders? Founding what?
There have been countless SPACs gone public to much fanfare, and it turns out, they have added a new fashion statement: founders shares.
The first prospectus I saw mention founders shares (and there are already others) was for Far Point Acquisition Corporation. Even if you don't follow SPACs, you may have heard of this one.
It made some mainstream headlines because it is being led by former NYSE head, Tom Farley. According to a Bloomberg article (not included a link here), Mr. Farley did a lot to make SPACs easier to list.
Given that I hadn't seen founders shares before in a SPAC, I was intrigued. I assumed it was a new way to pay management of the SPAC a little extra money. Nothing out of the ordinary there.
And, the structure is fairly simple. Some "founders" provided money to the fund to set it up in return for stock. In this case it is class B stock, which is convertible into class A stock when the SPAC actually buys another company.
Class A stock is the common stock that the public got in the stock offering. OK, again, nothing earth shattering.
Then I started looking at the numbers. My first thought was, "holy expletive expletive Batman!"
My next thought was, "this SPAC is going to complete an acquisition, or somebody's getting kneecapped."
If the SPAC, for whatever reason, cannot do an acquisition (can't find the right company, the shareholders don't like the deal, etc.) then the SPAC warrants become worthless. Zero, nil, zilch, zip, nada, none.
This makes SPAC warrants somewhat like a lottery ticket. They are either worth something (a deal is announced, then approved) or they are worth nothing (no deal, SPAC dissolved).
It follows that anything that influences whether a deal is more or less likely impacts the value of the warrants.
Now let's talk numbers.
The "founders" of Far Point Acquisition Corporation (which includes Dan Loeb and his hedge fund, Third Point) put $25,000 into the fund which before that "had no assets, tangible or intangible."
No, I didn't leave off a zero on that, it's twenty-five thousand with a T. (So you don't have to come back and reread it.)
So what do you think the founders get in return for that $25,000 if an acquisition is done? How about a 10X return? That's pretty good, but come on, you're a Wall Street insider here, think bigger.
100X? Now we're talking. Show me the money! (that credit card commercial has totally messed up the Jerry Maguire reference). But no, wrong again.
OK, here I'm going to make an assumption. I'll make it quick, stick with me. The Units went public at $10 a share.
The units include one share of common (class A, or what our class B can be converted into) and one-third of a warrant. (Even half-warrants aren't fashionable this year.)
Some of the warrants were sold in a private placement (more on that below) at $1.50 per warrant.
For those of you who are not familiar with warrants: A warrant is like a stock option where you have the right to convert the warrant units into real common stock (usually class A) shares. And some of the warrants are traded publicly on the stock exchanges and some are privately sold in a private placement depending on when the warrant gains a public listing.
So if the Units went public at $10 a share and a warrant costs $1.50 per warrant at a private placement, and that warrant can be converted into class A common stock at $10 a share, you can do the math yourself as to how much money you make [with hands over fist].
So, I'm going to put the value of a share of common stock (A and B are equivalent for this purpose) at $9.50 per share ($10 minus $.50 for one-third warrant).
So, where does that get us? OH YEAH, how many shares of common stock did the "founders" get for their $25,000?
In March 2018 the founders got 11,500,000 shares of stock. Hang on, don't do the math yet.
Because in June 2018, before the SPAC came public, before it had identified or acquired a company .... basically before it had done anything, the "founders" paid themselves a stock dividend.
TWO dividends in fact. The result, the founders received 15,812,500 shares for their $25,000.
Yeah, me too. I can only guess at what was said in the discussion to do the stock dividend.
Maybe, "We just got Mr. Farley from the NYSE to sign on to lead this thing. Who's going to question ANYTHING that we do. Another scotch Jimmy, and what the hell, let's pay ourselves a stock dividend."
Whatever the discussion, at $9.50 a share, the founders are looking to make $150,218,750 (minus their $25,000 investment, I'm not even going to bother subtracting that). BTW, that's over 6,000X their original investment. Hey guys, can I be a founder next time, please, please, please, please?
BUT, remember, they only get this money if Far Point actually acquires a company. So ... my bet is they WILL acquire a company, and the Far Point warrant is going to be a winning lottery ticket.
Far Point added a few additional incentives to make sure a deal is done.
First, the founders have agreed to vote for a deal if a target is selected. Those founders are swell guys.
Remember, if a SPAC selects a target, the SPAC must still put it to the shareholders to vote whether they want to do the deal or get their money back. The Far Point Structure, in which the founders own 20% of the SPAC, means they only need a little over 32% of the shareholders to vote favorably.
Well, at least the founders didn't evade the democracy process in approaching this thing. The founders adhered to the democracy principle by allowing majority opinion wins.
So let's do the math: 20% + 32% is 52%. That's a majority opinion and anything above 50% is a majority opinion. This is a democracy principle.
But the founders don't have a majority opinion on their 20% holding -- do they? Read on!
Second, Third Point agreed to purchase 9,766,667 warrants (presumably at no more than 25 cents per Unit -- hey, you're the buyer and seller -- buying and selling to yourself, and thus, you can set whatever price you want).
These newly purchased warrants are addition to Third Point's original stake in the founder shares, and if no deal is done all these warrants will go to zero.
Third, there is an agreement between Third Point (or Cloudbreak Aggregator, an affiliate of Third Point in the Cayman Islands) and the SPAC, that Third Point will purchase shares of the SPAC which are redeemed by public shareholders.
Remember that SPACs are funded and owned by public investors -- big or small. And if these investors don't like the deal they can sell their SPAC shares in the public market.
Basically, if enough of the public shareholders don't like the deal and want their money back, Third Point will purchase those shares and vote them for the deal. YEAH! RIGHT! The rich get richer!
Fourth, and finally, I've pointed out having a single owner of a block of SPAC shares may make a deal more likely. In other words, you look to attract enough big pocket investors so that you can convince them to vote for the deal because big pocket investors can sway the voting scale quickly as appose to small investors where you need lots and lots and lots of them to vote in favor to sway the outcome of vote.
If that owner has experience with special situations and arbitrage even better. In other words, you can do a backroom deal with that big pocket investor by promising them lucrative terms on the deal and get that investor to vote for the deal.
If we could pick one person to want to own our SPAC shares, and add more likelihood of a deal, it might be this guy, Daniel Och. Who better than a former Goldman Sachs risk arb guy. Mr. Och and his funds have purchased 15,000,000 of the Far Point units.
Given all the various structures that comprise the Far Point Acquisition Corporation, this SPAC IS going to acquire a company. One of the main risks in owning SPAC warrants prior to the announcement of an acquisition is that if the SPAC does not do a deal and the warrants go to zero. That will not happen here. (This article was written in 2019)
Update on Far Point Acquisition Corporation
Here is a press release from Far Point Acquisition Corporation: August 24, 2020
NEW YORK, Aug. 24, 2020 /PRNewswire/ -- Far Point Acquisition Corporation (NYSE: FPAC, FPAC.UN, and FPAC.WS) a special purpose acquisition company ("FPAC"), announced that its stockholders voted to approve the proposed business combination transaction (the "Transaction") with Global Blue Group AG ("Global Blue") at a Special Meeting held for this purpose on August 24, 2020. Holders of 53,505,646 shares of FPAC's Common Stock, or approximately 67.68% of the issued and outstanding shares, voted in favor of the Transaction. The parties expect the closing of the Transaction to occur August 28, 2020. FPAC also announced that stockholders holding 48,708,994 shares of FPAC's Class A Common Stock have elected to redeem their shares in connection with the closing of the Transaction.
|
Tesla can issue more stock to sell to the public and use that cash to pay off the bondholders. But having stock prices higher benefit Tesla because Tesla can sell less shares to earn more cash. On top of that, if Tesla's stock is higher than$359.87 Tesla doesn't have to issue more shares to sell -- they can just elect to convert the bonds into shares of Tesla's stock.
So having Tesla's stock stay high has many benefits to Tesla and that's why Wall Street was speculating that Musk's motive was to drive up Tesla's stock when he tweeted about taking Tesla private.
Now in about two years later, Tesla's stock was trading above $2,000 in July and in much of the early August of 2020, making the convertible bonds talk above a moot point or non-issue.
In other words, Tesla and Elan Musk won the battle against critics particularly short sellers who bet against him and his company and lost their shirts to the tune of $38 billions in 2020 alone.
And my gosh, Elan Musk won big against his critics and at the same time propelled himself to the tune of being the richest people on earth (worth $194.8 billion as of January 7, 2021), beating Jeff Bezos ($185.8 billion) of Amazon for the top spot.
Update: August 12, 2020. Tesla stock came down to earth to: $1,374/share after Tesla's stock price climbed above $2,000 recently.
On August 12, 2020, Tesla announced a five-for-one stock split set to take effect at the end of August 2020 after Tesla's stock price climbed above $2,000 recently.
Every Tesla shareholder will receive four additional shares for every share they currently own when trading ends on August 28, 2020, the company said in a press release. The value of all five shares will equal the stock's pre-split closing price from that same day.
Trading of Tesla shares on a split-adjusted basis will begin on August 31, 2020, and is expected to be right around of Tuesday's (August 11 2020) closing level, in which the newly split shares would be worth right around roughly $274 each. The split alone won't change Tesla's market cap. Yet cutting the barrier to entry for smaller investors to buy in could boost Tesla's share price.
Update: December 31, 2020. Tesla stock: $706/share up from the post split of $274 a share on August 28, 2020.
So everything with yield curve has to do with bond yields -- and bond yields have to do with the economics principle supply and demand.
The higher the bond yield, the lower the demand for that bond. Likewise, the lower the bond yield, the higher the demand for that bond.
Say what? The higher the bond yield, the lower the demand for that bond? Does it make any sense?
Take it this way: When you see stores with advertisement that says something like 30% off, 40% off, 50% off, or 60% off, they're telling you that their products are not in high demand and to get rid of those products, they have to lower prices to entice customers to buy them.
Bonds work the same way: When there are lack of demand for the bonds, their yields are typically higher because seller(s) of those bonds will offer bond buyers with higher interest rates to entice bond buyers to buy those bonds; and therefore, making those bonds having higher yields. Make sense?
So the yield curve is the graph that plotted the bond yields. Economists use charts and graphs to interpret the activities of the economy and bond yields is a very important key that drives economic activities.
In the graph illustrated below shows the yield curve for the 10-year bonds, and it is not upward slopping, but rather, it is flattening, which means that the demand for 10-year bonds are in high demand, driving their yields down, hence the flattening of the yield curve. In other words, people are buying more 10-year bonds than they're buying 2-year bonds.
The bond market is a great predictor of future economic activity and future levels of inflation, both of which directly affect the price of everything from stocks and real estate to household items.trending toward zero
, or flat. See the graph below:The horizontal line that has number 0 (zero) can be viewed as the benchmark 2-year bond yield (for easier interpretation). It is actually a line representing maturity dates, however. A 10-year bond is plotted against this horizontal zero-line with varying maturity periods.
If the plotted graph representing a 10-bond goes below zero -- an "inversion" in which the yield on the two-year bond would be greater than the 10-year -- that traditionally signals something is very wrong in the market.If you ever wanted to learn how to program computer programs, particularly learning how to build a website of your own, this tutorial helps you get started and points you in the right direction to achieving your programming goal. This tutorial is not meant to teach you everything about how to program, but rather, a 'get started' guide that guides you in the right direction to help you get started.
For a complete and specific area of programming, such as a particular language you are interested in learning, please check out tutorials on the Web by Googling it. There are lots of free tutorials on the Internet, particularly YouTube.com and the HTML as noted in the following.
A good place to get started is the W3Schools
And here is another good place to get started:
Learn How to Code OnlineAnd here is a forum for the above site where you can ask the experts on programming topics:
Learn How to Code Online: Codecall Programming Forums!As listed in the W3Schools mentioned above, you need to start with HTML and CSS first, and then proceed to server-side languages such as PHP and then to the client-side languages such as Javascript, and then you should learn databases as well, such as PDO and MySQL, and then to specialized languages such as jQuery and Ajax, in that order. So the order you should follow is: HTML, CSS, PHP, Javascript, PDO, MySQL, jQuery, Ajax.
Also as a programmer, you should also get yourself familarized with CURL as CURL is one of the core technologies that is a "must know" for any programmer, if you're going to be able to program interactive applications effectively.
CURL is an interactive client-server technology (or model) that enables you to make request/response to and from the client and server. In other words, in a client-server model, you use a client-side language like Javascript to send a request for content stored on the server and you use a server-side language like PHP to send the content back to the client. So this is called a request/response or client-server model.
cURL stands for client URL.
For more on CURL, please Google it and start from there.
If you have time, you should learn DOM as well. For an introductory course on DOM, see chapter 3 to 7 of my Ajax book called Introduction to Ajax.
If you mastered all the languages mentioned above, you should be able to build any sophisticated Web applications easily. After that, if you want to learn other languages as well, then you should learn those languages listed in the W3Schools mentioned above in no particular preferential order guideline.
W3Schools above listed category under Javascript, which includes Node.JS and other excellent server-side languages as well, but you really only need to learn PHP is enough for a while. PHP is the most popular server-side language out there, but Node.JS is getting more popular as it is very good in streaming applications, such as movie shows and other live streaming applications.
However, you can accomplish the same thing using PHP, but it is easier to program streaming applications using Node.JS than PHP as Node.JS is specifically built for streaming applications.
If you want to learn how to program sophisticated desktop applications, start with Java, and then C++, and then either Python or C# (pronounce 'see sharp') or even Delphi if you dear to venture into the deep end of the programming language world. But the first three or four listed above is sufficient and you can accomplish any sophisticated desktop applications just fine.
If you just want to learn only one desktop language, Java is a very good choice to learn.
If you dear to venture into the deep end of the programming language world for desktop, here is a link to an excellent language called Delphi
Furthermore, if you dear to venture into the deep end of the programming language world for desktop and for cross-platform mobile applications such as building apps for smartphones (i.e., iOS and Android platforms) using Delphi, here is a link to an excellent tutorial titled: Building your first Native Mobile Applications for iOS and Android
Typically, you would need to find an iOS platform SDK to build your iPhone mobile applications that can run on an iOS platform and then you would need to find an Android platform SDK to build your mobile applications that can run on Android platform.
With Delphi mobile platform, you can build both iOS and Android mobile applications using only one SDK platform. This is very convenient and powerful and not to mention the simpicity of having to learn only one platform for building cross-platform mobile applications.
Again, if you dear to venture into the deep end of the programming language world for both desktop and mobile, start with the free and full-featured Community Editions of Delphi and C++Builder. Community Editions of Delphi and C++Builder are designed to help you get started programming. These powerful IDEs provide all the features you need to quickly explore robust app development.
When Community Edition launched it made all the features of the Professional Edition of Delphi and C++Builder free to students and hobbyists in the community: including mobile platforms, desktop database, and the full source code for the runtime libraries. Now the 10.4.2 Sydney update brings the absolutely latest features and updated platform support to Delphi & C++Builder Community Edition.
There's no better way to build powerful native applications for iOS, Android, Windows, and macOS from a single codebase than using the robust and easy-to-learn Delphi language. This makes it the ideal choice for students or anyone who just wants to get things done.
C++Builder is your choice if you want to master the mysteries of the curly brace (see illustration below). It unlocks a huge variety of C++ standard libraries, while still giving you access to the powerful runtime libraries included in Delphi. This is a winning combination for C++ development.
Note that in Delphi, the syntax is slightly different than with other languages, for example, in other languages you use curly braces or brackets '{}' to group your block of code, such as the beginning and ending of a block of code. For example:
In other languages:
class MyClass
{
public function aMethod()
{
// code block
if (true)
{
//code block
}
}
}
In Delphi:
Type
TMyClass = class
public
class function aMethod()
begin
// code block
if (true)
begin
//code block
end; // end if (true) block
end; // end function aMethod()
end; // end class TMyClass block
// Notice that in Delphi it uses keywords 'begin' and 'end', followed by a semicolon ';', to seperate
// between blocks.
// Note also that in a main program (not shown here) the final 'end' should be a period '.' instead of
// a ';' to end the whole program.
The Community Editions of Delphi & C++Builder are designed for students and hobbyists. If that is you, and you are new to programming, then download the free Community Edition of your choice [Delphi 10.4.2 CE or C++Builder 10.4.2 CE] and register for the free Learn to Code Summer Camp.
Community Editions are available free of charge to developers, and organizations with fewer than five developers. Here are the download links Start Learning Delphi for Free: Delphi & C++Builder FREE Community Editions Start Learning Delphi for Free: Download the FREE Delphi Community Edition Start Learning Delphi for Free: Download the Free C++Builder Community Edition
If W3Schools doesn't have the topics I mentioned here, just Google around and you'll get plenty of results for you to get started. The same thing is also true for begining Delphi programmers: Just Google around and you'll find plenty of resources to get you full speed learning Delphi. Have fun learning!
Here are the steps on how to get started programming for beginners:
First, you need an editor to write your programs with. There are lots of free editors on the Web such as NetBeans IDE, a free, open-source Integrated Development Environment for software developers, particularly for desktop applications. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, and even dynamic languages such as PHP, JavaScript, Node.JS, Groovy, and Ruby.
NetBeans IDE is easy to install and use straight out of the box and runs on many platforms including Windows, Linux, Mac OS X and Solaris.
So if you are interested in learning to program desktop applications and as well as Web applications, NetBeans IDE, unlike many other editors mentioned below, is suiteable for both applications.
Other text editors that are very popular among beginners are Notepad++, Sublime Text, Atom, Ultra Edit, TextMate, BBedit, MAX's HTML Beauty++, etc. Please Google them to learn more about them. Or you can just Google the term 'free text editors' and you'll get a bunch of results.
Personally, I have been using two text editors simultaneously: one is NetBeans IDE because I need to compile and run programs written in Java for desktop applications and another is MAX's HTML Beauty++ for doing non-desktop applications for the Web, such as Javascript, Node.JS, HTML, CSS, etc. MAX's HTML Beauty++ is perfectly suitable for these Web languages.
As noted above, MAX's HTML Beauty++ is only suiteable for building Web applications and NetBeans IDE is suiteable for both desktop and Web applications.
What I like about MAX's HTML Beauty++ old version is that it color-codes all PHP code in yellow and leaving all other programming languages code as a default color, which is a non-color black and white.
Using MAX's HTML Beauty++ old version, you can preview your webpages instantly while you're still building it by switching back and forth between a "preview" and an "edit" mode. This is a great feature for beginners trying to learn how to program Web applications.
If you are not into building sophisticated desktop applications, here is MAX's HTML Beauty++ download that will do the job just fine for building Web applications.
The download above is an older version, which happens to be my favorite version that I am still using it to this day, and I prefer this older version over the newer version, which is a 2004 version. If you prefer the newer 2004 version, here it is: http://www.htmlbeauty.com/bsetup.exe download
As a matter of fact, any text editor, including Microsoft NotePad that comes with your Windows operating system, will do just fine for building Web applications.
Also all these downloaded text editors come inside an archive compression zip file. You need to extract them once you've downloaded them using any archive unzip application. There are lots of free archive zip applications available on the Internet. See the following.
Once you've downloaded your favorite text editor, including my favorite text editor MAX's HTML Beauty++, extract it using free zip extracting applications like WinZip ZIP Extractor Express Zip WinRAR or WinRAR here! PeaZip
The archive zip application is a compression program that compresses the content into a small version of the original plain text content so that it can be sent over the Web easily and faster. It compresses the content and decompresses (or extracts) that same content once you extract it. Think of the archive zip program as a plastic zip bag that you put food in it and then seal it to protect the food from spoiling.
Once you've downloaded your favorite archive zip application, you need to install it as you normally would with any other applications by following the installation instruction. It shouldn't be that hard to install the archive zip application. You can install it in any directory of your choosing and it doesn't need to be in a particular directory at all.
Just make sure that you say "yes" when it prompts (you) if you want the installation program to create an icon in the desktop for that particular archive zip application. If you said "yes," it will create an icon for that archive zip application and it will put that icon on your desktop pane. Self-explanatory!
Actually, you don't even need to have the icon shown on your desktop pane unless you need to open it to create an archive zip application to put your files in to send your files to the server. In that case, you definitely need to have an icon shown on your desktop pane.
So basically, after you'd installed your favorite archive zip on your laptop/desktop you can use it to extract your downloaded text editor that came inside the zip archive by clicking on your "raw zipped" downloaded favorite text editor.
Remember that all downloaded applications come inside an archive compression zip application -- it is totally zipped or compressed. So you need to extract/uncompress the downloaded text editor, which came inside the archive compression zip application.
Just clicking on the "raw zipped" downloaded text editor in raw format and it will open up (automatically) the archive zip application that you had installed on your computer. You see, this is why you don't need to create an icon on your computer pane because you don't need to click it to open it. It opens the archive zip application automatically every time you click on the "raw zipped" downloaded application.
Say you just downloaded a text editor called MAX's HTML Beauty++ and all you have to do is double click on that downloaded apllication and it will automatically open up your favorite zip archive application and extract your downloaded text editor for you without you having to find your zip archive application icon to double it and open it. It opens automatically for you once you double click on the downdloaded text editor.
Once it opens up the archive zip application it should show that your text editor is inside the archive zip application. In that archive zip screen, it shows a lot of options you can do, such as "create archive" for creating archive zip application packages, and "extract" option, which is to extract the (current) downloaded application. Follow the on-screen instruction and you'll be fine! It is very easy to use archive zip applications.If for some reasons you need to send files to the server, you can open the archive zip application by just clicking on the icon shown on your computer pane and it will open the archive zip application for you to use. This is why you need to allow the installation program to create an icon on your computer pane so that you can open it and use it easily.
Let's say you have some photos, or any other content for that matter, and you want to send them to a remote server, you can put those photos/content/files in an archive zip application and send them to your remote server or any server you have accessed to. And then create a link to that archive zip file name and your users will be able to download those content from your website.
Once your users downloaded the photo content they can decompress (or extract) that photo content from the archive zip application to be viewed at their own leisure.
For example, say you have a bunch of photos and you want to create an archive zip application by opening the archive zip application and then clicking on "create archive" or for some archive applications just say "create", and it will open a screen to allow you to create the archive zip application. From there, just follow the on-screen instructions and you'll be fine.
Among the instructions is that it asks for a file name for the archive zip application you're creating; for example, you can name it as "myphoto" without any extension and it will create an empty archive zip application without any content in it.
From there, you can put your photos/content inside that newly created archive zip application by copy and paste them or if the photos/content/files are on the computer pane, you can drag and drop them easily. It is very easy to create and move content into the archive zip applications.
Now you have your photos/content/files inside your newly created archive zip application with a file name for that archive zip application and ready to go. Next, you can upload the entire newly created archive zip application to your server so that your users can download them.
To allow your users to download them, you need to create a link to that particular archive zip application that you just uploaded to your server. For example, say you upload your archive zip application to your website, which has a directory called "download," you can create a link somewhere on your website page like this: <a href="http://www.mywebsite.com
/download/myphoto.zip">
download my photos!</a>
. That is it!
Pay special attention to the extension, which in the above case, it is a ".zip
" extension. So you need to specify the exact extension in order for it to work. Different archive compression applications have different extensions and they are named accordingly in a variety of extensions, i.e., .zip
, .ar
, .rar
, .pea
, etc. Check your particular archive compression applications for the extension they use.
The process just described is how you allow your users to download anything from your website -- the same sort of thing you see other websites allow their users to download some content from their websites.
Well, the first step is a little too lengthy than I would have liked but I just wanted to be very clear and precise to help you along!
Next, you'll need a local webhost to build and test your applications offline -- that is, you're using a fake web server to build and test your web applications offline on your computer without having to rent a live "real" web server. Once you've built and tested your web applications offline, you can decide to get a real web server to host your web applications online so that your website can be viewed by people all over the world.
As a matter of fact, most experienced programmers, including myself, use "fake" server to build and test applications on a daily basis. So I strongly recommend beginning programmers to do the same and use localhost to build and test your web applications. Once you finished building and testing your applications and then you can find a real web server to host your websites. Google around using phrases like this: "free webhosting services" to find a real web hosting service provider to host your websites. There are lots of them out there.
Check out my other tutorial at the bottom of this page titled: 'Migrating your website to a real live server' for a free web hosting service provider that I found on the Internet when I Googled around using phrases like this: "free web hosting services".
That free web hosting service provider that I found is one of the best free web hostings out there. I used that free web hosting to host one of my websites as well. You, too, can signup for a free web hosting account with them and use it to host your website just like I do.
Please DO NOT use free web hosting to build and test your web applications because it slows down other people using the same host. All free web hostings are shared hosting: meaning all users of the shared hosting are routed through the same bandwidth and if lots of people use their live hosting to build and test their web applications, it slows down the shared hosting traffic.
So please use your localhost to build and test your web applications.To get a "fake" web server, usually called localhost, you can search the web using a term like "localhost webserver", or you can Google a specific term like "WAMP server", "XAMPP server", "MAMP server", "VAGRANT server", or DOCKER.i.
Once you've identified which one you want, go ahead and download and then install it on your local machine, preferably on your laptop/desktop. You can choose to install it in any location on your desktop/laptop and it doesn't matter; however, for ease of use, choose the default setting shown on the installation prompts.
Once you've installed your localhost web server, you're ready to build and test your web applications just like if you had rented a real live web server from a hosting vendor. The only difference is that your "fake" web server is locally run and is not visible on the web like a real web server does. Most of the instructions on the web are self-explanatory and are very easy to follow even for beginners who never know how to program a single program. You can check out Youtube.com on tutorials on these topics as well.
Once you've installed a WAMP local host web server, all the required applications, such as the Apache (web server), MySQL (database), PHP programming language, and as well as the PHPmyAdmin (a MySQL application), are all bundled and installed completely into your local laptop/desktop to work with each other seamlessly.
In WAMP, you can work with databases using MySQL to store and retrieve data, as well as using PHP programming language to program your web applications. WAMP is not restricted to just PHP, however -- you can use other languages as well.
WAMP is a popular alternative of XAMPP for Windows. However, you can use XAMPP as well and it doesn't take much time to install XAMPP either. But developers may prefer to use WAMP since it is specifically crafted for Windows only -- unlike, XAMPP, which can be used for Linux and Mac OS as well.
However, both platforms are equally stable and provide the same functionality.
So you can choose any platform amongst the two to fulfill your objective. But all those who are searching for guidance on how to install WAMP on Windows system should follow the below-given steps. So let's get going!!
How to Install WAMP on Windows
Download the WAMP Server: Wampserver 64 bit x64
You want to choose a 64 bit version. The 32 bit is for older computers or laptops, which is outdated in today's programming world. If you're using computers that is still using a 32 bit, by all mean choose 32 bit version. To check what version your computer is running on, go to the status bar at the lower left corner of your computer screen and type in the search box: control panel and press enter.
The "Control Panel" screen should pop up. In that screen, look for a section called "System and Security" or "System and Maintenance" or anything that has a word "System" on it. For Windows 7, 8, 10, it should says "System and Security." Click on that topic and a "System and Security" screen should pop up.
Next, look for the topic "System" and click on that topic and a "System" screen should pop up. In that screen under the "System" section it lists the "System type" which should say a "64-bit Operating System or 32-bit Operating System, depending on your computer. If it says "64-bit Operating System, your computer is running on a 64-bit operating system. "32-bit Operating System", otherwise.
Initiate WAMP Server Installation Process. I'm being lazy and for the rest of the installation instructions, I will refer to an excellent instruction on the web: here it is: click here!
In that instruction, be careful in step 2. WAMP server looks for a version of Microsoft Visual C++ re-distributable package already installed on your laptop/desktop. Most of the laptops/desktops come with a Microsoft VC++ re-distributable package already pre-installed, so you don't have to do anything. However, for some odd reasons, some laptops/desktops came without that Microsoft Visual C++ re-distributable package pre-installed.
In that case, you might have to search the web for "Microsoft Visual C++ re-distributable package" and download it and install it using default settings contains in its installation application. When you install Microsoft Visual C++, it is very easy and self-explanatory, the same way you install a WAMP server -- they both are self-explanatory, allowing you to just use default settings.
FYI: If you look in the "Control Panel" screen mentioned earlier, it should shows Microsoft Visual C++ installed already; and in that case, WAMP server will find it and use it to complete the installation process, and thus, you don't need to do anything on your part, sparring you from having to search the web.
Once you get through the Microsoft Visual C++ re-distributable package installation process and proceeds to the end of the installation process, the last thing the WAMP server installation guide will prompt you to do is, to enter/choose a text editor. You can accept a default text editor in the prompt or choose your favorite text editor to use with your newly installed WAMP server. It looks something like this:
It's okay one way or another as it is not very significant if you do not choose a particular text editor or not as a default text editor for the WAMP server to use. It won't effect/harm your WAMP server at all. For beginners, I suggest that you choose the default text editor chosen by the installation.
However, I strongly recommend you just select a text editor of your choice or just leave it as a default text editor that the WAMP server chooses, which is a Microsoft notepad. In other words, by choosing a particular text editor doesn't restrict you from using other text editors with your WAMP server.
It also will prompt you to enter/choose a default web browser to use with your newly installed WAMP server. Likewise, by choosing a particular web browser doesn't restrict you from using other web browser with your WAMP server either. So it looks something like this:
Once you've finished the installation process, you can use the "fake" web server to build and test your web applications offline as you normally would with a "live" real web server. To start, click on the arrow or status icon usually on the lower right corner of your laptop/desktop screen to activate the tap that shows the "fake" web server options listing.
Note: From time to time, if you're using Windows operating system, Windows operating system usually runs updates to update its software drivers and the rest of its system files automatically and periodically. If you're using Windows OS, you may have experienced this update many times already and it's kind of annoying as well, but it's a necessary task for Windows OS, according to Microsoft.
One of the annoying things that this update causes is that it causes the WAMP server to not function properly once the update is completed.
If you experienced this and having issues with your WAMP server to not function properly, just un-install your WAMP server completely from your system and then re-install it again and it should work properly.
Yes, it is very annoying having to un-install and re-install your WAMP server every time a Windows operating system runs its update.
Make sure that you move all of your "projects" in the "www" directory to a different location (or directory) before un-installing your WAMP server; because if you don't, it will delete all of your projects in the "www" directory.
Let's continue on:
It should show an icon that looks something like below with a status icon that usually appears on the lower right corner of your laptop/desktop screen, but with a particular color on it. A green color (as shown below) signifies as the wampserver is ready to use; a grey or pink color, it is not activated; a yellow, it is partially ready and in the process of being ready as it is finishing the loading process.
So in essence, every time you start/load or turn on your wampserver, it goes through a series of steps to initialize the wampserver, showing the colors of its readiness from grey to pink to yellow to green. Green means the wampserver is ready for usage.
If it is inactive, all you have to do to fire up your wampserver is to double click on the default icon on your laptop pane that looks something like below:
Usually, when you turn off your laptop, WAMP server is also turned off and no longer active and the green status icon you see above is not shown. When it is turned off, the status icon that usually appears on the lower right corner of your laptop/desktop screen doesn't show the WAMP server icon because it is not activated.
To activate it or turn on your WAMP server, double click on the default icon on your laptop pane to get it activated.
Once your "fake" server is up and running, you can do pretty much just about anything you do with a "live" server. You can click on the arrow next to the green status icon to reveal other options, such as a PHP icon to see what version of PHP is installed on your "fake" server; as well as clicking on PHPmyAdmin to work with database.
Note that PHPmyAdmin in your "fake" server doesn't require you to enter a password, although you can if you want -- but why bother to complicate yourself in having to enter a password every time you try to access your PHPmyAdmin? So just enter 'root' for the username and don't enter a password on the password field. Leave it blank as it is!
Just click "Go" without entering a password and it will open the PHPmyAdmin panel for you.
In the PHPmyAdmin, you can create databases and tables and do pretty much just about anything about database programming.
As stated above, when a localhost is up and running the status icon usually appears on the lower right corner of your laptop/desktop screen. Click on the arrow to reveal the the localhost options. In this option window, you can find a lot of options to choose from, such as PHPmyAdmin, just to name one.
You can click on the particular option to work with it. For example, among the options there is a "localhost" option. Click on that "localhost" option and it will open up a screen that looks something like the following:
As you can see, it shows the configuration status of the localhost such as what version of various entities: Apache, PHP, MySQL, etc. Most of them are really not useful for beginners. Experienced programmers can make use some of these configurations.
The diagram above combines with the one listed below is what it should looks like inside a real server. This localhost web server mimmicks what a real server looks like but on an offline mode.
The localhost also contains a section in the lower half that lists content that is more relevant to beginning users of Wampserver, such as tools and your actual projects that you had created. For example, below it lists three projects that I've created: advanced, framework, noon2noon.com:
If you click on one of the projects it will execute/load the project. For example, if I click on the project called noon2noon.com
it will load and display my website called noon2noon.com
.
However, you can load your website on the browser's url bar as well, the same way you normally would with your regular "live" server. That is the typical usage of localhost: you don't need to load your website through localhost option window, but instead, through a normal loading process in the browser's url bar.
You should try to create a very simple website and click on it in the project section to see what it looks like on your "fake" server. When you create your projects, place them in a directory where you installed your Wampserver. For example, in my case, I installed my Wampserver in a directory that looks like the following:
As you can see, my root directory is called "Desktop" followed by a directory that I named it as "wamp64" followed by a directory called "www." This directory called "www" is created automatically by the installation, so you really don't have to create it yourself. The only directory that you need to create and specify during the Wampserver installation is the "wamp64" part or whatever name you choose. I chose to name it "wamp64."
Any projects you build have to be placed inside the "www" directory in order to be visible by your localhost. For example, in my case, I placed my projects in that "www" directory and inside my project noon2noon.com
it contains content that looks like the following:
One particular content worths mentioning is the index.php file. This is the main starting script file that the server/localhost calls first thing when you try to load the website by typing in your url bar like http://www.noon2noon.com
. However, that is for your real live web server when you migrate your website to a real web server.
But for this tutorial, you're using a fake server called localhost; and therefore, you have to type in the browser bar using localhost instead of www.
So you can simply replace the domain specification 'www' with 'localhost' and just type the name of the folder following it as, in my case, http:
//localhost/noon2noon.com
or simply just localhost/noon2noon.com
and it will load the website automatically.
For my project advanced, which its inside content looks similar to my other two projects framework and noon2noon.com, I can just do the same like this http:
//localhost/advanced
, and likewise for the other one http:
//localhost/framework
, and both websites will load automatically.
Notice that you can include an index.php
or index.html
file as well since it doesn't require you to specify an extension of either a .php
or a .html
and it will work just fine. For examples: http:
//localhost/noon2noon.com
/index
, http:
//localhost/advanced
/index
, http:
//localhost/framework
/index
, and all websites will load automatically.
Please note that when you migrate your websites to a real web server, you have to abide by your web hosting's rule, which tells you what kind of an extension of either a .php
or an .html
that their server is using. If they're using a .php
extension, you'll have to rename your index
file with that extension. Likewise, if they're using an .html
extension, you'll have to rename your index
file extension as such.
For a localhost
, it doesn't matter. It will read from either .php
extension or .html
file extension.
For starter, in your case, just create an index.php
or index.html
file and throw it in a folder and place that folder inside the "www
" directory and type http:
//localhost/ follows by your folder name in the url browser bar to see your website comes alive. Try it!
If your website doesn't come alive and showing a weird screen that looks like the following, it means that for some reason the localhost cannot read your index file. Or it means that the route in the url bar that you typed is incorrect. The localhost can't find the file contains in the route that you typed in the url bar:
As you can see, there is no index file listed in the main folder. I deleted it on purpose and the localhost can't find the file contains in the route that I typed in the url bar.
Localhost server is very vague in their error messaging system and that's a source of frustation for a lot of new programmers.
Remember that each website has to have only one index file as a main starting application file. So make sure that you have a functional index file and it has to be only one index file. No index.php and index.html at the same location vying as the main starting application file.
Once you are finished building and testing, you can migrate your projects to your live real web hosting server. For example, in my case, I just take the folder containing the particular project, i.e., noon2noon.com folder, and upload the entire folder to my real live server. That's how you get started in developing website applications.
For starter, you can create a folder and name it and then create an index.php
or index.html
file as well as other files/folders and put them inside that folder that you just created which contains other files/folders as well and upload the entire folder using FileZilla. See my other tutorial on how to use FileZilla.
That is it! Very simple to have your own "fake" server. And from here, the possiblities are endless! Have fun programming!
For beginners, building a website is a daunting task, even for very simple websites that don't have ordinary bells and whistles and are still very challenging to say the least. Fortunately, the folks at the W3Schools.com provide all sort of examples and ready-made web site templates to help beginners get started.
Let's take a look at one template and illustrate how you (beginners) can build your own web site using the ready-made template and customize it to suite your taste.
First go to https://www.w3schools.com/w3css/w3css_downloads.asp and download the css definition (or file) and place it in a folder called css. The default file name is w3.css. You can rename the css file if you like, say css.css or style.css. If you do, don't forget to change the css file name accordingly in your index.php file at the css area at the top of the index.php file to reflect the change in the css file name.
Next, in the same page where you're downloading the css, look on the left side under the category name Examples and try to find a topic name called W3.CSS Templates. Or you can go to https://www.w3schools.com/w3css/w3css_templates.asp
You can scroll down to see the various templates available to use. Pick one and go from there!
If the templates mentioned in the above link is not enough for your tastes, you can find more templates to use right here!
Once you decided which one you want to use, go ahead and click on the "Try it Yourself" button to see the actual code.
Next, copy the actual code, character by character, without missing any character. In other words, no typos in your part or else your web site won't look as intended. If your web site doesn't look like it is intended, try to go back and see if you had any typos in your copied code.
The folks at W3Schools.com used some sort of techniques, such as disabling the "hot link" ability, to disable the copy and paste ability from the web browser. So you can't actually use your web browser to copy and paste the code shown in the templates. You'll have to use advanced editors or tools to copy and paste the code in the templates.
For beginners, advanced tools are out of reach, so just try to copy it manually by hand character by character until you completely copied everything in the template. Yes, it is a pain, but that is what you have to do to learn. Name that template as either index.php or index.html. This is your main index file -- or your main web site file.
Once you have the css file downloaded as well as the template copied and name it as either index.php or index.html, then you need to create a main folder as well as a css folder.
Next, create another folder called image and put all the images/photos that you want to use in your website in that image folder.
You can name them whatever names you like for any folders you create, i.e., MyWebsite, MyFirstProject (for the main folder), css, style (for the css folder), image (for the image folder), etc.
You need to put the index.php or index.html as well as the css folder and the image folder in the main folder. The css file containing the css definitions should be inside the css folder, while the image folder contains all images you need to use. Self-explanatory!.
So your main folder contains everything you need. So you need to put everything in this main folder, including other folders as well such as css, image, etc. The index file should be among the css and image folders as peers at the same level.
That's all you need for this simple website. Three folders: main folder (i.e., MyWebsite or MyFirstProject, or whatever), css folder, and image folder. Plus the index.php/index.html and all three are peers -- meaning they are at the same level in directory. For example:
Of course, you can have more folders and other contents as well as your website gets sophisticated, but for this simple website the three items are all you need for now.
As you can see, I put my main folder called MyWebSite inside the www localhost folder for building and testing web applications. The index.php file contains the content listed below and the actual rendering page content is shown in the following.
Let's see one particular template called "Social Media Template" taken from W3Schools.com website in the W3.CSS Templates category, but I customized it slightly. Here it is:
Here is the actual code along with the commented out code that contained in the original template shown in the W3Schools.com:
File: index.php
<!-- all HTML document start with a !doctype -->
<!-- it is a Document Type declaration to tell the web browser of -->
<!-- what version of the HTML markup language in which a web page -->
<!-- is written. -->
<!-- every time a browser reads a document such as an HTML document it -->
<!-- needs to know what version the HTML markup language is written in -->
<!-- so that it can parse it correctly. -->
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<!-- a meta (<meta>) tag provides metadata information about -->
<!-- the HTML document. -->
<!-- a metadata information will not be displayed on the page, -->
<!-- but will be machine/browser parsable. -->
<!-- metadata elements are typically used to specify page description, -->
<!-- keywords, author of the document, last modified, and other metadata. -->
<!-- you put metadata in <meta> tags-->
<!-- meta (<meta>) tags are documents for the browsers to read and -->
<!-- used the meta content, for example, you can specify a view port -->
<!-- device dimension such as width. -->
<!-- the word "meta" means self or itself, referring to itself or -->
<!-- a self-referential. -->
<!-- so a self-referential. -->
<!-- meta tags can contain attributes, i.e., name and content. -->
<!-- the two most frequently used in a meta tag are name and content -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- the following link is the css link stored in folder named css -->
<link rel="stylesheet" href="./css/mobile.css">
<!-- the following two links were broken down to fit the screen display -->
<!-- these two links are specialized css stored in cloudflare.com -->
<!-- you only need to incude these links if you use awesome fonds and -->
<!-- bootsrap code like form input boxes, textarea, and dialog boxes -->
<!-- you can check out bootstrap tutorials on W3Schools as well! -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/
css/font-awesome.min.css">
<link rel="stylesheet"
href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/
3.2.0/css/bootstrap.min.css">
<!-- the following three lines link to jquery, bootstrap, and -->
<!-- my own Javascript files -->
<script src="https://code.jquery.com/w3/1.4.5/jquery.w3-1.4.5.min.js">
</script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="javascript/javascript.js"></script>
</head>
<!-- this is the start of the web site body -->
<!-- the 'class' attribute specifies the css that this body uses to -->
<!-- beautify itself -->
<!-- disregard the theme class, but make use of the color class -->
<!-- this is where you set your body background color, light grey, in this -->
<!-- case! -->
<!-- check out the list of pre-made colors at the bottom of this listing -->
<!-- in this body is where you also set your text size using w3-tiny -->
<!-- w3-small, w3-medium, w3-large, w3-xlarge, w3-xxlarge, -->
<!-- w3-xxxlarge, w3-jumbo -->
<!-- as you use W3Schools templates, you can put multiple css classes in an
element, i.e., <body>, <div>, <span>, <p>, <a>, <button>, <img>, etc. -->
<body class="w3-theme-l5 w3-light-grey">
<!-- some of the following codes were broken down into multiple lines -->
<!-- to fit the screen display -->
<!-- Navbar -->
<!-- this is the div that wraps around the navbar -->
<div class="w3-top">
<!-- in the navbar you can style the look-and-feel using css classes. -->
<!-- for example, you can make the navbar thicker or thiner by specifying -->
<!-- the class as w3-padding-tiny, w3-padding-small, -->
<!-- w3-padding-large, etc. -->
<!-- in the example site illustrated above I style the navbar as w3-blue! -->
<div class="w3-bar w3-theme-d2 w3-left-align w3-small w3-blue">
<a class="w3-bar-item w3-button w3-hide-medium w3-hide-large w3-right
w3-padding-small w3-hover-white w3-small w3-theme-d2"
href="javascript:void(0);" onclick="openNav()">
<i class="fa fa-bars"></i></a>
<!-- notice that the anchor tags contain "#" used in place ---->
<!-- of the actual url that you need to provide! ---->
<!-- the "#" is just a placeholder for the real url! ---->
<!-- so don't forget to replace "#" with the actual url! ---->
<!-- for example: "http://www.example.com/homefolder/myfile.php" ---->
<a href="#" class="w3-bar-item w3-button w3-padding-large w3-theme-d4">
<i class="fa fa-home w3-margin-right"></i>Logo</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="News"><i class="fa fa-globe"></i></a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="Account Settings"><i class="fa fa-user"></i></a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="Messages"><i class="fa fa-envelope"></i>
<div class="w3-dropdown-hover w3-hide-small">
<button class="w3-button w3-padding-large" title="Notifications">
<i class="fa fa-bell"></i>
<span class="w3-badge w3-right w3-small w3-green">3</span>
</button>
<!-- here is again the use of "#" as a placeholder for the real url! ---->
<div class="w3-dropdown-content w3-card-4 w3-bar-block"
style="width:300px">
<a href="#" class="w3-bar-item w3-button">One new friend request</a>
<a href="#" class="w3-bar-item w3-button">John Doe posted on
your wall</a>
<a href="#" class="w3-bar-item w3-button">Jane likes your post</a>
</div>
</div>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-right
w3-padding-medium w3-hover-white" title="My Account">
<img src="./image/paul_tuon.jpg" class="w3-circle"
style="height:23px;width:23px" alt="Avatar"> </a>
</div>
</div> <!-- end div class="w3-top" -->
<!-- the following code block is the code that gets used instead of the -->
<!-- above navbar when a mobile device is used to load -->
<!-- this web site -->
<!-- Navbar on small screens -->
<!-- here is again the use of "#" as a placeholder for the real url! ---->
<div id="navDemo" class="w3-bar-block w3-theme-d2 w3-hide
w3-hide-large w3-hide-medium w3-large">
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 1</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 2</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 3</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">My Profile</a>
</div>
<!-- now the navbar code is done! -->
<!-- at this point there are 0 open <div> tag -->
<!-- Page Container -->
<!-- remember that there are typically four sections in a web site: -->
<!-- the head section, the navbar section, the main body content, -->
<!-- and the footer -->
<!-- so the following is the start of the main content of the web site, -->
<!-- and this section is the biggest section. -->
<!-- this main container has a maximum width of 1400 pixels -->
<!-- and spaces between the navbar and the start of the main -->
<!-- container or content is 80 pixels. -->
<!-- take a look at the gap in the web site above for a visual guide! -->
<!-- for a better practice is to use percentage as in 100% -->
<!-- of the screen width rather than specifying the exact width! -->
<!-- that way it works much better on different screen sizes! -->
<!-- pay special attention to one class: w3-container -->
<!-- 'container' is sort of a basket to hold something, in this case, -->
<!-- it holds a grid of column layout -->
<!-- in a later case, it holds a (small) profile container area! -->
<!-- as you can see, class w3-container can be used inside -->
<!-- another container area as well -->
<!-- in this case, this w3-container class acts as the main content -->
<!-- holder, holding everything in the body of the entire page! -->
<!-- remember that the whole website has four sections: navbar section, -->
<!-- head section, the main body section, and the footer section! -->
<!-- so this div has a w3-container class to hold the entire content -->
<!-- and this entire content is actually the 3-column layout grid! -->
<div class="w3-container w3-content" style="max-width:1400px; margin-top:80px">
<!-- The Grid -->
<!-- W3Schools provides grid system for us to use! -->
<!-- for a complete in depth tutorial see W3Schools on this topic! -->
<!-- pay special attention to a class called w3-row -->
<!-- so two classes that are central to W3Schools framework are -->
<!-- w3-container and w3-row -->
<!-- you'll make use of these two classes very often! -->
<!-- basically, the grid must be inside the container: w3-container! -->
<!-- and the container, w3-container, can contain rows of content! -->
<!-- this grid starts with a class w3-row -->
<!-- this is sort of the anchor div to hold the entire grid or one row! -->
<!-- class w3-row is a grid system. think of w3-row as a table row where -->
<!-- you can arrange grid data content in it. so if you have data content -->
<!-- that are normally arranged in rows in a table, you can use this -->
<!-- w3-row to hold those data content in table rows-like display! -->
<!-- however, in this website we have only one row of a table row! -->
<!-- if we have more data content that needs another table row, all we -->
<!-- have to do is create another div containing this w3-row class and -->
<!-- put it after the closing of this div shown below! -->
<!-- see the closing of this div later! -->
<!-- if you look at the website illustrated above, you'll see the -->
<!-- whole content body is inside a div that contains the class w3-row. -->
<!-- this is one row of content containing a three-column layout. -->
<!-- after the closing of this div w3-row, you can create more rows -->
<!-- of content by creating more divs that contain the class w3-row. -->
<!-- for each div that contains w3-row you can format your grid layout -->
<!-- any way you like, say, a four-column layout or whatever layout -->
<!-- configuration you desire! -->
<!-- here is the row! -->
<div class="w3-row">
<!-- here is inside the row! -->
<!-- now inside the anchor div or more specifically, -->
<!-- the w3-row (or grid) there are columns layout: a one-column -->
<!-- display, a two-column display, a three-column display, etc. -->
<!-- in this case, we have a three-column layout web site! -->
<!-- Left Column -->
<!-- this is the left column in the web site: see profile area column! -->
<!-- m3 is short for medium 3 out of 12 columns: 3-twelfth of the grid -->
<!-- W3Schools uses three sizes: small (s), medium (m), large (l) -->
<!-- so if you see s1 means a small scale grid with one-twelfth of -->
<!-- the grid. m7 is a medium scale layout with 7/12 of the total -->
<!-- grid layout. -->
<!-- likewise, an l2 (that is "L" and 2) means 1arge scale layout-->
<!-- with a two-twelfth of the total grid layout! -->
<!-- here, we have a medium scale with 3/12th of the total grid layout -->
<!-- as you can see, this left column has a class w3-container to hold -->
<!-- the entire left side area! -->
<!-- as stated above, class w3-container can be used inside this -->
<!-- container area as well! sort of containers within container! -->
<div class="w3-col m3 w3-container">
<!-- Profile -->
<!-- w3-card is a class to make the profile looks like a deck -->
<!-- of cards, w3-round will make the deck of cards rounded -->
<!-- edges on all 4 corners -->
<div class="w3-card w3-round w3-light-blue">
<!-- here is where class w3-container gets used to hold-->
<!-- a profile area -->
<div class="w3-container">
<h4 class="w3-center">My Profile</h4>
<p class="w3-center"><img src="./image/paul_tuon.jpg"
class="w3-circle" style="height:106px;width:106px"
alt="A Profile Picture"></p>
<hr>
<p><i class="fa fa-pencil fa-fw w3-margin-right
w3-text-theme"></i> Designer, UI</p>
<p><i class="fa fa-home fa-fw w3-margin-right
w3-text-theme"></i> Minneapolis, MN (US)</p>
<p><i class="fa fa-birthday-cake fa-fw w3-margin-right
w3-text-theme"></i> April 1, 2020</p>
</div>
</div>
<br>
<!-- Accordion -->
<!-- this block of code contains an accordion-like feature -->
<!-- when a user clicks on an item it slides down to reveal the content! -->
<!-- class w3-card is a css that made to look like a deck of cards -->
<div class="w3-card w3-round">
<div class="w3-pale-blue">
<!-- when a user clicks on "My Groups" it calls myFunction() -->
<!-- and it displays an accordion style revealing the content -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<button onclick="myFunction('Demo1')" class="w3-button
w3-block w3-theme-l1 w3-left-align">
<i class="fa fa-circle-onotch fa-fw w3-margin-right">
My Groups</i></button>
<!-- here is again w3-container gets used! -->
<!-- note that w3-hide hides the content inside the -->
<!-- div when the page is loaded! -->
<!-- it will only reveal the content when a user clicks -->
<!-- on "My Groups"! -->
<div id="Demo1" class="w3-hide w3-container">
<p>Some text..</p>
</div>
<!-- when a user clicks on "My Events" it calls myFunction() -->
<!-- and it displays an accordion style calendar of events -->
<!-- by sliding down to reveal the content -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<!-- right here where you might want to place a break: "<br>" -->
<!-- to make the gap between the two accordion item elements! -->
<!-- so instead of using "<br>" you might want to use -->
<!-- css styling to specify how much gap you want because -->
<!-- "<br>" might be bigger/smaller gap than you like! -->
<!-- so using css to style the gap is probably a good idea! -->
<button onclick="myFunction('Demo2')" class="w3-button w3-block
w3-theme-l1 w3-left-align"><i class="fa fa-calendar-check-0
fa-fw w3-margin-right"> My Events</i></button>
<!-- here is again w3-container gets used! -->
<!-- again w3-hide hides the content inside the -->
<!-- div when the page is loaded! -->
<!-- it will only reveal the content when a user clicks -->
<!-- on "My Events"! -->
<div id="Demo2" class="w3-hide w3-container">
<p>Some other text..</p>
</div>
<!-- likewise, when a user clicks on "My Photos" it calls -->
<!-- myFunction() and it displays an accordion style album -->
<!-- of photos by sliding down to reveal the photos in a -->
<!-- two-column layout -->
<!-- if you provide photos in the below container: a photo -->
<!-- album container, it will display them when a user -->
<!-- clicks on "My Photos" -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<!-- right here where you might want to place a break: "<br>" -->
<!-- to make the gap between the two accordion item elements! -->
<!-- so instead of using "<br>" you might want to use -->
<!-- css styling to specify how much gap you want because -->
<!-- "<br>" might be bigger/smaller gap than you like! -->
<!-- so using css to style the gap is probably a good idea! -->
<button onclick="myFunction('Demo3')" class="w3-button
w3-block w3-theme-l1 w3-left-align">
<i class="fa fa-user fa-fw w3-margin-right"> My Photos
</i></button>
<!-- class w3-container is used to hold the photos album layout -->
<!-- w3-hide is a class to hide the element: diplay: none -->
<!-- as you can see, when the web site is loaded, "Demo3" is -->
<!-- not shown! -->
<!-- it will only be shown when a user clicks on -->
<!-- "My Photos" button! -->
<div id="Demo3" class="w3-hide w3-container">
<div class="w3-row-padding">
<br>
<!-- the following is where you put your photo album! -->
<!-- class w3-half is a grid layout as a two-column -->
<!-- layout relative to the class w3-container used -->
<!-- in the album layout so the photos are arranged -->
<!-- side by side as a two-column layout -->
<!-- inside the div or img tags you can embedd inline css to style your layout: width, height, etc. -->
<!-- for example: <div class="w3-half" style="width: 100px; height: 50px"> ... </div> -->
<div class="w3-half">
<img src="./image/paul_tuon.jpg" style="width: 100%; height: 50%"
class="w3-margin-bottom">
</div>
<div class="w3-half" style="width: 200px; height: 150px">
<img src="./image/graduation.jpg"
class="w3-margin-bottom">
</div>
<!-- this is another two-column grid stacking below the above photos -->
<div class="w3-half">
<img src="./image/paul_tuon.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="./image/graduation.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<!-- this is another two-column grid stacking below the above photos -->
<div class="w3-half">
<img src="image/example5.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="image/graduation.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
</div> <!-- end div class="w3-row-padding" -->
</div> <!-- end div id="Demo3" -->
</div> <!-- end div class="w3-white" -->
</div> <!-- end div class="w3-card w3-round" -->
<!-- this is the end of an accordion-like feature! -->
<!-- at this point there are still 3 open div -->
<!-- Interest: the miscellaneous content of interest! -->
<!-- w3-hide-small is to not display the content when mobile -->
<!-- device is used to load the web site! so "Interests" content -->
<!-- won't be loaded if mobile device is being used to load -->
<!-- this web site -->
<div class="w3-card w3-round w3-teal w3-hide-small">
<div class="w3-container">
<p>Interests</p>
<p>
<span class="w3-tag w3-small w3-theme-d5">News</span>
<span class="w3-tag w3-small w3-theme-d4">W3Schools</span>
<span class="w3-tag w3-small w3-theme-d3">Labels</span>
<span class="w3-tag w3-small w3-theme-d2">Games</span>
<span class="w3-tag w3-small w3-theme-d1">Friends</span>
<span class="w3-tag w3-small w3-theme">Games</span>
<span class="w3-tag w3-small w3-theme-l1">Friends</span>
<span class="w3-tag w3-small w3-theme-l2">Food</span>
<span class="w3-tag w3-small w3-theme-l3">Design</span>
<span class="w3-tag w3-small w3-theme-l4">Art</span>
<span class="w3-tag w3-small w3-theme-l5">Photos</span>
</p>
</div>
</div>
The following block of code contained in the original template
<!-- Alert box -->
<!-- when a user clicks on this div area an alert box pops up -->
<!--
<div class="w3-container w3-display-container w3-round w3-theme-14
w3-border w3-theme-border w3-margin-bottom w3-hide-small w3-red">
<span onclick="this.parentElement.style.display='none'"
class="w3-button w3-theme-13 w3-display-topright">
<i class="fa fa-remove"></i>
</span>
<p><strong>Hey,</strong></p>
<p>People are looking at your profile. Find out who!</p>
</div>
-->
</div> <!-- end left column -->
<!-- at this point there are still 2 open <div> tags -->
<!-- start middle column -->
<!-- this is the start of the middle column. -->
<!-- size m7 means 7/12 of the grid -->
<!-- as you can figure it out: there are 12 columns in the entire grid -->
<!-- if the left side column is m3, meaning 3/12 of the grid, -->
<!-- and middle column is 7/12 of the grid, -->
<!-- the right column has to be 2/12 of the grid! -->
<div class="w3-col m7">
<!-- right here where I add some new content to the middle column -->
<!-- I add a scrolling message board to make it more flashy. for example: -->
<div class="w3-row-padding">
<!-- notice that you need to use the entire length of the grid: m12 -->
<!-- meaning the entire middle column -->
<div class="w3-col m12">
<div class="w3-card-2 w3-round w3-white">
<div class="w3-container w3-padding">
<marquee bgcolor=white width="100%" height="50">
<font size="5" color="#FF66FF">
Welcome to the 21st century and beyond where digital mobile rules!</font>
<font size="5" color="#1883FF">More content to scroll!</font>
</marquee>
</div>
</div>
</div>
</div>
<div class="w3-row-padding">
<div class="w3-col m12">
<div class="w3-card w3-round w3-white">
<div class="w3-container w3-padding">
<h6 class="w3-opacity">Social Media Template</h6>
<p contenteditable="true" class="w3-border
w3-padding">Status: Feeling blue!</p>
<button type="button" class="w3-button w3-theme">
<i class="fa fa-pencil"></i> Post
</button>
</div>
</div>
</div>
</div>
<div class="w3-container w3-card w3-round w3-blue w3-margin">
<img src="./image/paul_tuon.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
<span class="w3-right w3-opacity">1 min</span>
<h4>John Doe</h4>
<hr class="w3-clear">
<p>This is just an ordinary content! You can put whatever
content you want!</p>
<div class="w3-row-padding" style="margin:0 -16px">
<!--
<div class="w3-half">
<img src="./image/graduation.jpg" alt="just a picturer"
style="width: 100%" class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="./image/paul_tuon.jpg" alt="another picture"
style="width: 100%" class="w3-margin-bottom">
</div>
-->
</div>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
<div class="w3-container w3-card w3-round w3-khaki w3-margin"><br>
<!--
<img src="./image/graduation.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
-->
<span class="w3-right w3-opacity">16 min</span>
<h4>Jane Doe</h4>
<hr class="w3-clear">
<p>Lorem ipsum dolor. Lorem ipsum dolor. Lorem ipsum dolor.
Lorem ipsum dolor. Lorem ipsum dolor.</p>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
The following block of code contained in the original template
<!--
<div class="w3-container w3-card w3-round w3-lime w3-margin"><br>
<img src="./image/paul_tuon.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
<span class="w3-right w3-opacity">30 min</span>
<h4>Angie Jane
<hr class="w3-clear">
<img src="./image/gradution.jpg" class="w3-margin-bottom"
style="width:100%">
<p>Lorem ipsum dolor. Lorem ipsum dolor. Lorem ipsum dolor.
Lorem ipsum dolor. Lorem ipsum dolor.</p>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
-->
<!-- on the left side column there is an accordion slide down/up -->
<!-- feature which contains three sections: My Groups, My Events, -->
<!-- My Photos! you can use that code example to place your -->
<!-- accordion feature anywhere on the website! -->
<!-- let's put that same accordion feature in the middle column at -->
<!-- the very bottom just before the start of the footer! -->
<!-- just remember that each accordion item must contains -->
<!-- a unique id, e.g., group, event, photo! -->
<!-- start accordion style feature! -->
<!-- Accordion -->
<div class="mobile-card mobile-round">
<div class="mobile-pale-blue">
<!-- when a user clicks on "My Groups" it will call -->
<!-- myFunction() and it displays an accordion -->
<!-- style revealing the content -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<button onclick="myFunction('group')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align">
<i class="fa fa-circle-onotch fa-fw
mobile-margin-right"> My Groups</i>
</button>
<div id="group" class="mobile-hide mobile-container">
<p>Some text..</p>
</div>
<!-- when a user clicks on "My Events" it will call -->
<!-- myFunction() and it displays an accordion -->
<!-- style calendar of events by sliding down to -->
<!-- reveal the content! -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<button onclick="accordion('event')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align">
<i class="fa fa-calendar-check-0 fa-fw
mobile-margin-right"> My Events</i>
</button>
<div id="event" class="mobile-hide mobile-container">
<p>Some other text..</p>
<div>
<!-- likewise, when a user clicks on "My Photos" it calls -->
<!-- myFunction() and it displays an accordion style -->
<!-- album of photos by sliding down to reveal the photos -->
<!-- in a two-column layout -->
<!-- if you provide photos in the below container: a photo -->
<!-- album container! it will display them when a user -->
<!-- clicks on "My Photos" -->
<!-- the below layout is a two-column layout displaying -->
<!-- two photos side by side! -->
<!-- in this example, there are six photos displaying -->
<!-- in pairs to make it three rows! -->
<!-- you might want to experiment using other elements such -->
<!-- as div or span or other elements instead of button! -->
<span class="hljs-string"><button onclick="accordion('photo')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align"><i class="fa fa-user
fa-fw mobile-margin-right"> My Photos</i>
</button>
<div id="photo" class="mobile-hide mobile-container">
<div class="mobile-row-padding">
<br>
<div class="mobile-half">
<img src="./image/paul_tuon.jpg" style="width: 100%"
class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="image/paul_tuon.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
</div> <!-- end div class="mobile-row-padding" -->
</div> <!-- end div id="photo" -->
</div> <!-- end div class="mobile-pale-blue" -->
</div> <!-- end div class="mobile-card mobile-round" -->
<!-- end accordion style feature! -->
</div> <!-- end middle column -->
<!-- start right column -->
<!-- here it is: right column is 2/12 of the grid -->
<div class="w3-col m2">
<div class="w3-card w3-round w3-aqua w3-center">
<div class="w3-container">
<p>Upcoming Events:</p>
<img src="./image/image_105.jpg" class="w3-margin-bottom"
style="width:100%">
<p><strong>Holiday</strong></p>
<p>Friday 15:00</p>
<p><button type="button" class="w3-button w3-theme-14
w3-block">Info</button></p>
</div>
</div>
<div class="w3-card w3-round w3-pink w3-center">
<iv class="w3-container">
<p>Friend Request</p>
<!--
<img src="./image/graduation.jpg" class="w3-margin-bottom"
style="width:50%">
-->
<span>Jane Doe</span>
<div class="w3-row w3-opacity">
<div class="w3-half">
<button type="button" class="w3-button w3-block-14
w3-green w3-section" title="Accept">
<i class="fa fa-check"></i></button>
</div>
<div class="w3-half">
<button type="button" class="w3-button w3-block-14
w3-red w3-section" title="Decline">
<i class="fa fa-remove"></i></button>
</div>
</div>
</div>
</div>
<br>
<div class="w3-card w3-round w3-purple w3-padding w3-center">
<p>ADS</p>
</div>
<br>
</div> <!-- end right column -->
<!-- here is the closing div for class w3-row! -->
</div> <!-- end grid containing class w3-row -->
<!-- right here, if you have more table rows-like data content, -->
<!-- you can add another div containing a class w3-row -->
<!-- after all the data content for this particular row has been -->
<!-- included, you can close out this div containing class w3-row -->
<!-- you can keep repeating this pattern over and over as you -->
<!-- need to make your website looks like table rows-like content! -->
<!-- the rows have to be inside the closing of the div that -->
<!-- contains w3-container. -->
<!-- as you may remember that the two most important classes in the W3 framework -->
<!-- css are w3-container and w3-row. -->
<!-- this means that you can nest these two classes inside one another in many -->
<!-- levels deep inside one another to make your grid as small or big as you want! -->
<!-- just remember that class w3-row has to be inside class w3-container! -->
<!-- and inside this class w3-row it can contain class w3-container as well to -->
<!-- nest your container inside a row! sort of a row of table that contains a container! -->
<!-- now inside this class w3-container can also contains nested rows -- I mean many 'rows' -->
<!-- of content (or container, more specifically, w3-container classes) -->
<!-- you can keep repeating this pattern over and over as you -->
<!-- need to make your grid looks like table rows-like content! -->
<!-- this means that you can grid your grids to line up very close or far apart from each other! -->
<!-- you can grid your grids to place your content anywhere in the website to position your -->
<!-- content to suite the look and feel like a drag and drop items arrangement in a desktop pane! -->
<!-- just remember that the rows have to be inside the container that contains w3-container! -->
<!-- and they all can be nested! -->
<!-- here is the closing div that contains class w3-container! -->
</div> <!-- end page container -->
<!-- at this point all open div tags have been closed -->
<!-- so the grid system is very simple. -->
<!-- it only contains two classes: w3-container and w3-row -->
<!-- that's all! -->
<!-- anything inside the grid are just ordinary html elements: -->
<!-- div, p, span, etc. -->
<!-- as you can see from the above grid, -->
<!-- it contains only one w3-container and one w3-row -->
<!-- that's all! -->
<!-- here is the last section of the website: footer -->
<!-- start footer -->
<footer class="w3-container w3-theme-d3 w3-padding-16">
<div>Follow us on social medias: Facebook, Twitter, Instagram!</div>
<div class="w3-right">Contact: john@doe.com</div>
</footer>
<script>
// Accordion
function myFunction(id)
{
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1)
{
x.className += " w3-show";
x.previousElementSibling.className += " w3-theme-d1";
}
else
{
x.className = x.className.replace("w3-show", "");
x.previousElementSibling.className =
x.previousElementSibling.className.replace(" w3-theme-d1", "");
}
}
// used to toggle on smaller screen when clicking on the menu button
function openNav()
{
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1)
{
x.className += " w3-show";
}
else
{
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>
/* THIS ENDS THE WEBSITE DEMONSTRATION CODE */
/* The rest are just extra contents to help you learn more about programming */
/* Here is the listing of colors. see css file for more definitions */
/* Colors */
.w3-amber, .w3-hover-amber:hover{color:#000!important;
background-color:#ffc107!important}
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;
background-color:#00ffff!important}
.w3-blue,.w3-hover-blue:hover{color:#fff!important;
background-color:#2196F3!important}
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;
background-color:#87CEEB!important}
.w3-brown,.w3-hover-brown:hover{color:#fff!important;
background-color:#795548!important}
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;
background-color:#00bcd4!important}
.w3-blue-grey,.w3-hover-blue-grey:hover,.w3-blue-gray,
.w3-hover-blue-gray:hover{color:#fff!important;
background-color:#607d8b!important}
.w3-green,.w3-hover-green:hover{color:#fff!important;
background-color:#4CAF50!important}
.w3-light-green,.w3-hover-light-green:hover{color:#000!important;
background-color:#8bc34a!important}
.w3-indigo,.w3-hover-indigo:hover{color:#fff!important;
background-color:#3f51b5!important}
.w3-khaki,.w3-hover-khaki:hover{color:#000!important;
background-color:#f0e68c!important}
.w3-lime,.w3-hover-lime:hover{color:#000!important;
background-color:#cddc39!important}
.w3-orange,.w3-hover-orange:hover{color:#000!important;
background-color:#ff9800!important}
.w3-deep-orange,.w3-hover-deep-orange:hover{color:#fff!important;
background-color:#ff5722!important}
.w3-pink,.w3-hover-pink:hover{color:#fff!important;
background-color:#e91e63!important}
.w3-purple,.w3-hover-purple:hover{color:#fff!important;
background-color:#9c27b0!important}
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;
background-color:#673ab7!important}
.w3-red,.w3-hover-red:hover{color:#fff!important;
background-color:#f44336!important}
.w3-sand,.w3-hover-sand:hover{color:#000!important;
background-color:#fdf5e6!important}
.w3-teal,.w3-hover-teal:hover{color:#fff!important;
background-color:#009688!important}
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;
background-color:#ffeb3b!important}
.w3-white,.w3-hover-white:hover{color:#000!important;
background-color:#fff!important}
.w3-black,.w3-hover-black:hover{color:#fff!important;
background-color:#000!important}
.w3-grey,.w3-hover-grey:hover,.w3-gray,
.w3-hover-gray:hover{color:#000!important;
background-color:#9e9e9e!important}
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,
.w3-hover-light-gray:hover{color:#000!important;
background-color:#f1f1f1!important}
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,
.w3-hover-dark-gray:hover{color:#fff!important;
background-color:#616161!important}
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;
background-color:#ffdddd!important}
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;
background-color:#ddffdd!important}
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;
background-color:#ffffcc!important}
.w3-pale-blue,.w3-hover-pale-blue:hover{color:#000!important;
background-color:#ddffff!important}
.w3-text-amber,.w3-hover-text-amber:hover{color:#ffc107!important}
.w3-text-aqua,.w3-hover-text-aqua:hover{color:#00ffff!important}
.w3-text-blue,.w3-hover-text-blue:hover{color:#2196F3!important}
.w3-text-light-blue,.w3-hover-text-light-blue:hover{color:#87CEEB!important}
.w3-text-brown,.w3-hover-text-brown:hover{color:#795548!important}
.w3-text-cyan,.w3-hover-text-cyan:hover{color:#00bcd4!important}
.w3-text-blue-grey,.w3-hover-text-blue-grey:hover,.w3-text-blue-gray,
.w3-hover-text-blue-gray:hover{color:#607d8b!important}
.w3-text-green,.w3-hover-text-green:hover{color:#4CAF50!important}
.w3-text-light-green,.w3-hover-text-light-green:hover{color:#8bc34a!important}
.w3-text-indigo,.w3-hover-text-indigo:hover{color:#3f51b5!important}
.w3-text-khaki,.w3-hover-text-khaki:hover{color:#b4aa50!important}
.w3-text-lime,.w3-hover-text-lime:hover{color:#cddc39!important}
.w3-text-orange,.w3-hover-text-orange:hover{color:#ff9800!important}
.w3-text-deep-orange,.w3-hover-text-deep-orange:hover{color:#ff5722!important}
.w3-text-pink,.w3-hover-text-pink:hover{color:#e91e63!important}
.w3-text-purple,.w3-hover-text-purple:hover{color:#9c27b0!important}
.w3-text-deep-purple,.w3-hover-text-deep-purple:hover{color:#673ab7!important}
.w3-text-red,.w3-hover-text-red:hover{color:#f44336!important}
.w3-text-sand,.w3-hover-text-sand:hover{color:#fdf5e6!important}
.w3-text-teal,.w3-hover-text-teal:hover{color:#009688!important}
.w3-text-yellow,.w3-hover-text-yellow:hover{color:#d2be0e!important}
.w3-text-white,.w3-hover-text-white:hover{color:#fff!important}
.w3-text-black,.w3-hover-text-black:hover{color:#000!important}
.w3-text-grey,.w3-hover-text-grey:hover,.w3-text-gray,
.w3-hover-text-gray:hover{color:#757575!important}
.w3-text-light-grey,.w3-hover-text-light-grey:hover,
.w3-text-light-gray,.w3-hover-text-light-gray:hover{color:#f1f1f1!important}
.w3-text-dark-grey,.w3-hover-text-dark-grey:hover,
.w3-text-dark-gray,.w3-hover-text-dark-gray:hover{color:#3a3a3a!important}
/* can you make sense of the above color definitions? */
/* let's take the last color definition above: the last line! */
.w3-text-dark-gray,.w3-hover-text-dark-gray:hover{color:#3a3a3a!important}
/* format it like this for a better visualization: */
.w3-text-dark-gray,
.w3-hover-text-dark-gray:hover
{
color:#3a3a3a!important
}
/* there are two classes: one is w3-text-dard-gray and the other */
/* is w3-hover-text-dark-gray which is attached to a hover mouse event. */
/* both of these two classes are assigned a color of a dark-gray */
/* which is #3a3a3a */
/* disregard the word "!important" for now. you can learn more in */
/* the css tutorial provided by W3Schools */
/* if you decide to add your own css definition, just add them to */
/* the bottom of the w3.css file. */
/* for example, if you find that the pre-made colors provided by */
/* W3Schools are not enough to your liking, you can add more color */
/* definitions to w3.css file like this: */
.w3-slate-gray
{
/** don't forget to put "!important" as well! **/
color:#ebe2e1!important
}
/* you can add other definitions to w3.css file as well because */
/* w3.css is only a css file framework that contains the universal */
/* commonly used definitions. */
/* so you most certainly need to add your own css defitions to */
/* the w3.css file */
/* A SECRET TO MEMORIZING CSS ATTRIBUTES or PROPERTIES */
/* one of the most confusing things in CSS is memorizing */
/* attributes/properties */
/* what if you have an attribute that says: */
/* padding: 10px 5px 20px 10px */
/* what does that mean? */
/* it means the padding property has four values:
top padding is 10px
right padding is 5px
bottom padding is 20px
left padding is 10px
*/
/* so how do you remember them? */
/* by brute force? */
/* that's what most people do: remembering it by brute force! */
/* but there is an easier way to remembering them and here's how: */
/* first, think of all HTML elements as a box. well, to be honest */
/* all HTML elements (div, p, span, a, button, i, etc) are boxes! */
/* and boxes have four sides and four corners! */
/* when you style an HTML element using padding you actually are */
/* styling the four sides and four corners! */
/* note: all properties that receive dimension values, i.e., padding, */
/* padding-top (-bottom, -left, and -right), margin, */
/* margin-top (-bottom, -left, and -right), border, color, etc., have */
/* four sides and four corners! */
/* now back to the padding example! */
/* if you follow the definition above it says padding 10px 5px 20px 10px */
/* it basically tells you to follow the box sitting stationary upright */
/* think of it as an ordinary box that is square sitting stationary upright */
/* an ordinary square box has four sides and four corners */
/* starting from the top of the box, which is 10px in height, and then follow */
/* the box around (from left to right), which is to the right side of the box! */
/* the KEYWORD is "around" (around the box)! */
/* in the right side of the box is where you find a 5px wide space gap! */
/* now you're done with the top and the right side of the box, so you continue */
/* on "around" the box, which is to the bottom of the box containing 20px in */
/* height! */
/* do you see what's happening? */
/* you basically follow the box "around" until you end up at the same place that */
/* you started, which is at the top of the box sitting stationary upright */
/* remember that a box has four sides and four corners! */
/* so you need to follow the box around the four corners! */
/* now you're at the bottom of the box and you continue to follow */
/* the box around, which is to the left side of the box containing */
/* a 10px wide gap! */
/* There you have it! */
/* A secret to memorizing the CSS attributes! */
/* what if you have something like the following illustrations? */
/* the same thing: follow the box! well, sort of! but you get the idea!
if the padding property has three values:
padding: 25px 50px 75px;
top padding is 25px
right and left paddings are 50px
bottom padding is 75px
above, start at the top of the box and move to the right side of the box!
now since right and left are together, it is a common value for both!
from there, you continue on around the box until all four sides are met!
so it goes like this:
the browsers style it by first styling the top and then the right and the
left (together) and then finally the bottom and it needs not go to the left
because it already done so earlier!
if the padding property has two values:
padding: 25px 50px;
top and bottom paddings are 25px
remember the common sense of saying left and right are together?
well, the same thing is also true: top and bottom are together!
so right and left paddings are 50px
this is where the rule is broken and makes an exception, but still not
too far from the rule! but the common sense kicks in as well!
top and bottom go together and right and left also go together!
as you can see, you follow the same box rule logic!
and add common sense to it!
if the padding property has only one value:
padding: 25px;
all four paddings are 25px
this one is not obvious to the human eyes but the browsers style it
using the box rule by first styling the top and then the right and then
the bottom and finally the left side of the box using only one value!
YES, THIS IS TRUE THAT BROWSWERS FOLLOW THE BOX SHAPE AROUND!
Do you see how simple it is to remember something that is so hard?
*/
/* YOUR OWN CSS DEFINITIONS */
/* most likely you will need to create your own CSS definitions */
/* to fullfil your needs! */
/* when you create your own definitions make sure that you use your */
/* own prefix and not the 'w3' prefix so that to avoid conflict! */
/* the color, padding, margin size, and text size are probably the */
/* most definitions you might need to create to fullfil your needs! */
/* for example, in most cases, you might need to style the left side */
/* margin only by using a 'my-padding-left-10 or my-margin-left-20 or
whatever margin or padding size you need! for example:
.my-padding-left-10
{
/* here is where you specify the size */
padding-left:10px!important;
}
.my-margin-left-20
{
/* here is where you specify the size */
margin-left:20px!important;
}
*/
/* there you have it! */
/* please check out tutorials at the W3Schools.com for more */
/* on this topic! */
For more about colors, please see my tutorial called an introduction to colors!
To get your own color check this out: color picker!
As mentioned earlier, the best place to advance your programming skills is the W3Schools. One particular topic that you might want to spend some time on learning is the image tutorial. You can learn how to place background images on your website as well as learning how to make your images work on mobile devices. So there are lots of topics available for you to improve your programming skills.
While you're at it learning about images, you might want to spend some time learning this important CSS class that makes displaying images awesome. The CSS class is called "clearfix" and can be found here: https://www.w3schools.com/howto/howto_css_clearfix.asp
Also, while you're at it learning about CSS, you might find these topics interesting and useful as well. Check the following topics out:
Best Free JavaScript & CSS/CSS3 Libraries For Modern Web Design
For more good stuffs, particularly photo galleries, sliders and plugins, please check out these sites:
https://www.jqueryscript.net/ https://frontendscript.com/ Unslider Simplest Carousel Query LightSliderThe latter one is a very simple carousel slider that suites very well for beginning programmers to use and learn. Check it out and see the demo by clicking on the "Example" menu. Try it!!!
There you have it! So go at it!!!
First, you need to visit the websites (particularly jqueryscript.net, https://frontendscript.com, Unslider Simplest Carousel) mentioned above and browse through their sliders. Once you've decided which one you want, go ahead and download their plugin and go from there. Each plugin has a demo for you to see a preview of what it should look like. It also has a tutorial to help you incorporate it in your website.
For this tutorial, I chose one of the jquery slider plugin that I found on the Internet and it is called CarouFredSel. Here is the link to that plugin: https://github.com/DivaVocals/carouFredSel
If you want to use this plugin, you need to download the plugin from the link mentioned above and extract it. The plugin as usual comes in a zip package, so you definitely need a zip software installed on your computer to extract it. See instruction on zip application earlier at the beginning of this tutorial.
Once you'd downloaded and extracted it, you can view the demo contains in file index.html inside the main folder called 'carouFredSel-master'. Just double-click on the file index.html and it will activate a demo screen showing the various styles of the slider that you can use to incorporate in your own website.
Let's incorporate that plugin in the example website shown above.
File: index.php
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- include jQuery + carouFredSel plugin -->
<!-- right here where you link to a jquery library that -->
<!-- is hosted in a Content Delivery Network or CDN -->
<!-- a CDN is just a central data network that mainly delivering -->
<!-- data content to users via a link! -->
<script type="text/javascript" language="javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- this CDN is owned by Google! -->
<!-- so Google is hosting the jquery library for everyone to link to -->
<!-- and use it instead of embedding that jquery library in their own script! -->
<!-- personally, I recommend that you embedd jquery library in your own -->
<!-- script instead of linking to a CDN! -->
<!-- to embedd a jquery library in your own script, do like the following -->
<!-- assuming you'd downloaded the jquery and place that library in a folder -->
<!-- called js/jquery -->
<script type="text/javascript" language="javascript"
src="js/jquery/jquery.min.js"></script>
<!-- to download the jquery library you -->
<!-- need to go to the jquery website: -->
<!-- https://jquery.com/download/ -->
<!-- click on the "Download the compressed, production" -->
<!-- and just hilight the whole file content and -->
<!-- copy and paste it in a blank file and name it accordingly! -->
<!-- in my case above, I named the jquery library file name to -->
<!-- 'jquery.min.js' -->
<!-- do not include both the CDN and the embedded library at the -->
<!-- same time because it might cause problems! -->
<!-- so use one or the other and not both of them at the same time! -->
<!-- next is the link to the carouFredSel library stored in the -->
<!-- plugin folder called carouFredSel-master -->
<script type="text/javascript" language="javascript"
src="jquery.carouFredSel-6.2.1-packed.js"></script>
<!-- optionally include helper plugins -->
<script type="text/javascript" language="javascript"
src="helper-plugins/jquery.mousewheel.min.js"></script>
<script type="text/javascript" language="javascript"
src="helper-plugins/jquery.touchSwipe.min.js"></script>
<script type="text/javascript" language="javascript"
src="helper-plugins/jquery.transit.min.js"></script>
<script type="text/javascript" language="javascript"
src="helper-plugins/jquery.ba-throttle-debounce.min.js"></script>
<link rel="stylesheet" href="./css/mobile.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/
css/font-awesome.min.css">
<link rel="stylesheet"
href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/
3.2.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/w3/1.4.5/jquery.w3-1.4.5.min.js">
</script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="javascript/javascript.js">
</script>
<!-- start plugin onDocumentReady -->
<script type="text/javascript" language="javascript">
$(function()
{
// Responsive layout, resizing the items
$('#foo4').carouFredSel(
{
responsive: true,
width: '100%',
scroll: 2,
items:
{
// the sliding content's width
// if you set it to half the
// screen size it will show two
// images at a time.
// if you set it to full screen
// (1000 pixels) it will show one
// image at a time.
width: 400,
// commenting out the optionally
// resize item-height option
// height: '30%',
visible:
{
min: 2,
max: 6
}
}
}
);
}
</script>
<style type="text/css" media="all">
.list_carousel
{
background-color: #ccc;
margin: 0 0 30px 60px;
width: 360px;
}
.list_carousel ul
{
margin: 0;
padding: 0;
list-style: none;
display: block;
}
.list_carousel li
{
font-size: 40px;
color: #999;
text-align: center;
background-color: #eee;
border: 5px solid #999;
width: 50px;
height: 50px;
padding: 0;
margin: 6px;
display: block;
float: left;
}
.list_carousel.responsive
{
width: auto;
margin-left: 0;
}
.clearfix
{
float: none;
clear: both;
}
.prev
{
float: left;
margin-left: 10px;
}
.next
{
float: right;
margin-right: 10px;
}
</style>
</head>
<body class="w3-theme-l5 w3-light-grey">
<!-- some of the following codes were broken down into multiple lines -->
<!-- to fit the screen display -->
<!-- Navbar -->
<!-- this is the div that wraps around the navbar -->
<div class="w3-top">
<div class="w3-bar w3-theme-d2 w3-left-align w3-small w3-blue">
<a class="w3-bar-item w3-button w3-hide-medium w3-hide-large w3-right
w3-padding-small w3-hover-white w3-small w3-theme-d2"
href="javascript:void(0);" onclick="openNav()">
<i class="fa fa-bars"></i></a>
<a href="#" class="w3-bar-item w3-button w3-padding-large w3-theme-d4">
<i class="fa fa-home w3-margin-right"></i>Logo</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="News"><i class="fa fa-globe"></i></a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="Account Settings"><i class="fa fa-user"></i></a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large
w3-hover-white" title="Messages"><i class="fa fa-envelope"></i>
<div class="w3-dropdown-hover w3-hide-small">
<button class="w3-button w3-padding-large" title="Notifications">
<i class="fa fa-bell"></i>
<span class="w3-badge w3-right w3-small w3-green">3</span>
</button>
<div class="w3-dropdown-content w3-card-4 w3-bar-block"
style="width:300px">
<a href="#" class="w3-bar-item w3-button">One new friend request</a>
<a href="#" class="w3-bar-item w3-button">John Doe posted on
your wall</a>
<a href="#" class="w3-bar-item w3-button">Jane likes your post</a>
</div>
</div>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-right
w3-padding-medium w3-hover-white" title="My Account">
<img src="./image/paul_tuon.jpg" class="w3-circle"
style="height:23px;width:23px" alt="Avatar"> </a>
</div>
</div> <!-- end div class="w3-top" -->
<!-- Navbar on small screens -->
<div id="navDemo" class="w3-bar-block w3-theme-d2 w3-hide
w3-hide-large w3-hide-medium w3-large">
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 1</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 2</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 3</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">My Profile</a>
</div>
<!-- now the navbar code is done! -->
<!-- at this point there are 0 open <div> tag -->
<!-- Slider Container -->
<div class="w3-container w3-content" style="max-width:1400px; margin-top:40px">
<div class="list_carousel responsive">
<!-- right here where the content of the slider is placed -->
<!-- notice that you can put any kind of content such as -->
<!-- text, images, etc., and as many content as you wish! -->
<!-- the slider will circle through the content until the end and loops -->
<!-- back to the beginning of the list! -->
<!-- the display of the images is dependenced on the size of the window -->
<!-- you set in the options of the function carouFredSel() above! -->
<!-- in the example above it was set to width: 400! -->
<ul id="foo4">
<li><img src="image/picture1.jpg"></li>
<li><img src="image/picture2.jpg"></li>
<li><img src="image/picture3.jpg"></li>
<li><img src="image/picture4.jpg"></li>
<li><img src="image/picture5.jpg"></li>
<li><img src="image/picture6.jpg"></li>
<li><img src="image/picture7.jpg"></li>
<li><img src="image/picture8.jpg"></li>
<li><img src="image/picture9.jpg"></li>
<li><img src="image/picture10.jpg"></li>
<li><img src="image/picture11.jpg"></li>
<li><img src="image/picture12.jpg"></li>
<li><img src="image/picture13.jpg"></li>
<li><img src="image/picture14.jpg"></li>
<li><img src="image/picture15.jpg"></li>
<li><img src="image/picture16.jpg"></li>
</ul>
<!-- for more tutorial on class "clearfix" please visit -->
<!-- https://www.w3schools.com/howto/howto_css_clearfix.asp -->
<div class="clearfix"></div>
</div>
</div>
<!-- Page Container -->
<div class="w3-container w3-content" style="max-width:1400px; margin-top:80px">
<!-- The Grid -->
<!-- here is the row! -->
<div class="w3-row">
<!-- Left Column -->
<div class="w3-col m3 w3-container">
<!-- Profile -->
<div class="w3-card w3-round w3-light-blue">
<div class="w3-container">
<h4 class="w3-center">My Profile</h4>
<p class="w3-center"><img src="./image/paul_tuon.jpg"
class="w3-circle" style="height:106px;width:106px"
alt="A Profile Picture"></p>
<hr>
<p><i class="fa fa-pencil fa-fw w3-margin-right
w3-text-theme"></i> Designer, UI</p>
<p><i class="fa fa-home fa-fw w3-margin-right
w3-text-theme"></i> Minneapolis, MN (US)</p>
<p><i class="fa fa-birthday-cake fa-fw w3-margin-right
w3-text-theme"></i> April 1, 2020</p>
</div>
</div>
<br>
<!-- Accordion -->
<div class="w3-card w3-round">
<div class="w3-pale-blue">
<button onclick="myFunction('Demo1')" class="w3-button
w3-block w3-theme-l1 w3-left-align">
<i class="fa fa-circle-onotch fa-fw w3-margin-right">
My Groups</i></button>
<div id="Demo1" class="w3-hide w3-container">
<p>Some text..</p>
</div>
<button onclick="myFunction('Demo2')" class="w3-button w3-block
w3-theme-l1 w3-left-align"><i class="fa fa-calendar-check-0
fa-fw w3-margin-right"> My Events</i></button>
<div id="Demo2" class="w3-hide w3-container">
<p>Some other text..</p>
</div>
<button onclick="myFunction('Demo3')" class="w3-button
w3-block w3-theme-l1 w3-left-align">
<i class="fa fa-user fa-fw w3-margin-right"> My Photos
</i></button>
<!-- class w3-container is used to hold the photos album layout -->
<!-- "My Photos" button! -->
<div id="Demo3" class="w3-hide w3-container">
<div class="w3-row-padding">
<br>
<!-- the following is where you put your photo album! -->
<!-- class w3-half is a grid layout as a two-column -->
<!-- layout relative to the class w3-container used -->
<!-- in the album layout so the photos are arranged -->
<!-- side by side as a two-column layout -->
<div class="w3-half">
<img src="./image/paul_tuon.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="./image/graduation.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<!-- this is another two-column grid stacking below above -->
<div class="w3-half">
<img src="./image/paul_tuon.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="./image/graduation.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<!-- this is another two-column grid stacking below above -->
<div class="w3-half">
<img src="image/example5.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="image/graduation.jpg" style="width: 100%"
class="w3-margin-bottom">
</div>
</div> <!-- end div class="w3-row-padding" -->
</div> <!-- end div id="Demo3" -->
</div> <!-- end div class="w3-white" -->
</div> <!-- end div class="w3-card w3-round" -->
<!-- this is the end of an accordion-like feature! -->
<!-- at this point there are still 3 open div -->
<!-- Interest: the miscellaneous content of interest! -->
<!-- w3-hide-small is to not display the content when mobile -->
<!-- device is used to load the web site! so "Interests" content -->
<!-- won't be loaded if mobile device is being used to load -->
<!-- this web site -->
<div class="w3-card w3-round w3-teal w3-hide-small">
<div class="w3-container">
<p>Interests</p>
<p>
<span class="w3-tag w3-small w3-theme-d5">News</span>
<span class="w3-tag w3-small w3-theme-d4">W3Schools</span>
<span class="w3-tag w3-small w3-theme-d3">Labels</span>
<span class="w3-tag w3-small w3-theme-d2">Games</span>
<span class="w3-tag w3-small w3-theme-d1">Friends</span>
<span class="w3-tag w3-small w3-theme">Games</span>
<span class="w3-tag w3-small w3-theme-l1">Friends</span>
<span class="w3-tag w3-small w3-theme-l2">Food</span>
<span class="w3-tag w3-small w3-theme-l3">Design</span>
<span class="w3-tag w3-small w3-theme-l4">Art</span>
<span class="w3-tag w3-small w3-theme-l5">Photos</span>
</p>
</div>
</div>
</div> <!-- end left column -->
<!-- at this point there are still 2 open <div> tags -->
<!-- start middle column -->
<div class="w3-col m7">
<!-- right here where I add some new content to the middle column -->
<!-- I add a scrolling message board to make it more flashy. for example: -->
<div class="w3-row-padding">
<!-- notice that you need to use the entire length of the grid: m12 -->
<!-- meaning the entire middle column -->
<div class="w3-col m12">
<div class="w3-card-2 w3-round w3-white">
<div class="w3-container w3-padding">
<marquee bgcolor=white width="100%" height="50">
<font size="5" color="#FF66FF">
Welcome to the 21st century and beyond where digital mobile rules!</font>
<font size="5" color="#1883FF">More content to scroll!</font>
</marquee>
</div>
</div>
</div>
</div>
<div class="w3-row-padding">
<div class="w3-col m12">
<div class="w3-card w3-round w3-white">
<div class="w3-container w3-padding">
<h6 class="w3-opacity">Social Media Template</h6>
<p contenteditable="true" class="w3-border
w3-padding">Status: Feeling blue!</p>
<button type="button" class="w3-button w3-theme">
<i class="fa fa-pencil"></i> Post
</button>
</div>
</div>
</div>
</div>
<div class="w3-container w3-card w3-round w3-blue w3-margin">
<img src="./image/paul_tuon.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
<span class="w3-right w3-opacity">1 min</span>
<h4>John Doe</h4>
<hr class="w3-clear">
<p>This is just an ordinary content! You can put whatever
content you want!</p>
<div class="w3-row-padding" style="margin:0 -16px">
<!--
<div class="w3-half">
<img src="./image/graduation.jpg" alt="just a picturer"
style="width: 100%" class="w3-margin-bottom">
</div>
<div class="w3-half">
<img src="./image/paul_tuon.jpg" alt="another picture"
style="width: 100%" class="w3-margin-bottom">
</div>
-->
</div>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
<div class="w3-container w3-card w3-round w3-khaki w3-margin"><br>
<!--
<img src="./image/graduation.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
-->
<span class="w3-right w3-opacity">16 min</span>
<h4>Jane Doe</h4>
<hr class="w3-clear">
<p>Lorem ipsum dolor. Lorem ipsum dolor. Lorem ipsum dolor.
Lorem ipsum dolor. Lorem ipsum dolor.</p>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
The following block of code contained in the original template
<!--
<div class="w3-container w3-card w3-round w3-lime w3-margin"><br>
<img src="./image/paul_tuon.jpg" alt="Avatar" class="w3-left
w3-circle w3-margin-right" style="width:60px">
<span class="w3-right w3-opacity">30 min</span>
<h4>Angie Jane
<hr class="w3-clear">
<img src="./image/gradution.jpg" class="w3-margin-bottom"
style="width:100%">
<p>Lorem ipsum dolor. Lorem ipsum dolor. Lorem ipsum dolor.
Lorem ipsum dolor. Lorem ipsum dolor.</p>
<button type="button" class="w3-button w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like</button>
<button type="button" class="w3-button w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment</button>
</div>
-->
<!-- Accordion -->
<div class="mobile-card mobile-round">
<div class="mobile-pale-blue">
<button onclick="myFunction('group')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align">
<i class="fa fa-circle-onotch fa-fw
mobile-margin-right"> My Groups</i>
</button>
<div id="group" class="mobile-hide mobile-container">
<p>Some text..</p>
</div>
<button onclick="accordion('event')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align">
<i class="fa fa-calendar-check-0 fa-fw
mobile-margin-right"> My Events</i>
</button>
<div id="event" class="mobile-hide mobile-container">
<p>Some other text..</p>
<div>
<span class="hljs-string"><button onclick="accordion('photo')"
class="mobile-button mobile-block mobile-theme-l1
mobile-left-align"><i class="fa fa-user
fa-fw mobile-margin-right"> My Photos</i>
</button>
<div id="photo" class="mobile-hide mobile-container">
<div class="mobile-row-padding">
<br>
<div class="mobile-half">
<img src="./image/paul_tuon.jpg" style="width: 100%"
class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="./image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="image/paul_tuon.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
<div class="mobile-half">
<img src="image/paul_tuon_graduation.jpg"
style="width: 100%" class="mobile-margin-bottom">
</div>
</div> <!-- end div class="mobile-row-padding" -->
</div> <!-- end div id="photo" -->
</div> <!-- end div class="mobile-pale-blue" -->
</div> <!-- end div class="mobile-card mobile-round" -->
<!-- end accordion style feature! -->
</div> <!-- end middle column -->
<!-- start right column -->
<!-- here it is: right column is 2/12 of the grid -->
<div class="w3-col m2">
<div class="w3-card w3-round w3-aqua w3-center">
<div class="w3-container">
<p>Upcoming Events:</p>
<img src="./image/image_105.jpg" class="w3-margin-bottom"
style="width:100%">
<p><strong>Holiday</strong></p>
<p>Friday 15:00</p>
<p><button type="button" class="w3-button w3-theme-14
w3-block">Info</button></p>
</div>
</div>
<div class="w3-card w3-round w3-pink w3-center">
<iv class="w3-container">
<p>Friend Request</p>
<!--
<img src="./image/graduation.jpg" class="w3-margin-bottom"
style="width:50%">
-->
<span>Jane Doe</span>
<div class="w3-row w3-opacity">
<div class="w3-half">
<button type="button" class="w3-button w3-block-14
w3-green w3-section" title="Accept">
<i class="fa fa-check"></i></button>
</div>
<div class="w3-half">
<button type="button" class="w3-button w3-block-14
w3-red w3-section" title="Decline">
<i class="fa fa-remove"></i></button>
</div>
</div>
</div>
</div>
<br>
<div class="w3-card w3-round w3-purple w3-padding w3-center">
<p>ADS</p>
</div>
<br>
</div> <!-- end right column -->
<!-- here is the closing div for class w3-row! -->
</div> <!-- end grid containing class w3-row -->
<!-- here is the closing div that contains class w3-container! -->
</div> <!-- end page container -->
<!-- here is the last section of the website: footer -->
<!-- start footer -->
<footer class="w3-container w3-theme-d3 w3-padding-16">
<div>Follow us on social medias: Facebook, Twitter, Instagram!</div>
<div class="w3-right">Contact: john@doe.com</div>
</footer>
<script>
// Accordion
function myFunction(id)
{
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1)
{
x.className += " w3-show";
x.previousElementSibling.className += " w3-theme-d1";
}
else
{
x.className = x.className.replace("w3-show", "");
x.previousElementSibling.className =
x.previousElementSibling.className.replace(" w3-theme-d1", "");
}
}
// used to toggle on smaller screen when clicking on the menu button
function openNav()
{
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1)
{
x.className += " w3-show";
}
else
{
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>
/* there you have it! */
/* a responsive mobile image slider */
/* when the website is loaded using a mobile */
/* device the slider showing one image sliding */
/* at a time! */
/* again, check out the plugin website mentioned earlier */
/* to find all kinds of plugins to use on your website! */
b
/* go at it! */
Fontawesome is a collection of ready-made images available to anyone for free. For a visual view on some examples of fontawesome images, go to my other website called "MondayThruSunday.COM," and look in all of the menu items and there should be a fontawesome in the front of the menu name for each menu item.
For example, for a menu name called "Home," there is a fontawesome image looking like a house in the front of the word "Home"; for a menu name called "Search," there is a fontawesome image looking like a magnifying glass in the front of the word "Search"; for a menu name called "Signup," there is a fontawesome image looking like three horizontal hash bars in the front of the word "Signup."
Fontawesomes are easy to use and most of all, you don't need to download them from somewhere and install them on your computer. They are available via the browser technology and the HTML.
To use fontawesomes, all you have to do is include the link to a CDN and then referring to its name as a class name inside your HTML element document -- the same way you refer to your CSS class names. See an illustration below.
Fontawesome images class starts with the word "fa fa-." For examples:
In the head <head> section of your HTML file, include the below link:
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
Again, a CDN (or Content Delivery Network) is just a central data
network that mainly delivering data content to users via a link!
Note that there are hundreds of CDNs out there that you can link to.
The above link is just one of those. Google has one and so does Bootstrap.
Here is a CDN from Bootstrap:
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
So it is just a matter of preference of which CDN to use and all will work just fine!
After you included the link, you can refer to the font awesome images as
you normally would the same way you refer to a CSS class. For example:
In the body <body> section of your HTML file, do this:
<div class="fa fa-home"></div> will display an image of a house:
<div class="fa fa-home"> Home</div> will display: Home
<div class="fa fa-bars"></div> will display an image of three horizontal hash bars:
<div class="fa fa-search"></div> will display an image of a magnifying glass:
<div class="fa fa-check"></div> will display an image of a checkmark:
<div class="fa fa-globe"></div> will display an image of a globe:
<div class="fa fa-cart-arrow-down"></div> will display an image of a shopping cart:
<div class="fa fa-plus"></div> will display an image of a plus sign:
There are thousands of fontawesome images available on the Internet for free to use. Just Google the term "fontawesome" and it will give a lot of results to choose from.
Earlier, I mentioned that you don't need to download fontawesome images anywhere from the Internet. That is true for the standard fontawesome images that are provided by the World Wide Web consortium.
However, for thousands of specialized third party fontawesome images like specialized shopping cart [where you can customize the inter-activity of the cart] and others, you need to download them from the Internet and store them in your folders and refer to them accordingly.
All CDNs do the same thing: they gather all of the fontawesome images and store them in a directory on their server and provide a link to the public to link to.
For more about fontawesome tutorials, please check out this site: https://www.w3schools.com/css/css_icons.asp
Here is another excellent fontawesome tutorial: https://www.w3resource.com/icon/font-awesome/web-application-icons/cart-arrow-down.php
Here is the official site of the standard fontawesome consortium site: https://fontawesome.com/icons/cart-arrow-down
Here is the official site of the standard fontawesome consortium site that lists a fontawesome cheat sheet that you can basically find a particular fontawesome image quickly: https://fontawesome.com/cheatsheet?from=io
Here is an interesting topic that you might find very useful: CSS Badge
/** showing the number of items in the cart **/
/** here, assuming you have a shopping cart that has a **/
/** variable called $cart_count that holds the number of **/
/** items in the cart **/
cart<a href="#"><span class="badge" id="cart-count"><?=$cart_count?></span></a>
For more tutorial on "badge" please click on the link below!
As mentioned earlier multiple times, the best place to advance your programming skills is the W3Schools. One of the many topics that you might want to spend some time on learning is the "dialog modal" box tutorial that can be found here: https://www.w3schools.com/bootstrap/bootstrap_modal.asp. With the modal dialog box, you can put all kinds of content to make your users interact with it.
Here are some of the interesting topics that you might want to spend some time learning:
https://www.w3schools.com/bootstrap/bootstrap_carousel.asp https://www.w3schools.com/bootstrap/bootstrap_affix.asp https://www.w3schools.com/bootstrap/bootstrap_glyphicons.asp https://www.w3schools.com/bootstrap/bootstrap_pagination.asp https://www.w3schools.com/bootstrap/bootstrap_images.asp https://www.w3schools.com/css/css_image_gallery.asp https://www.w3schools.com/css/css3_text_effects.asp https://www.w3schools.com/html/html_entities.asp
So there are lots of topics available for you to improve your programming skills. So go at it!!!
When you program websites, you might run into situations that require you to be creative instead of using CSS to accomplish your tasks. One of the neat trick is to use non-breaking space command or to put some spaces between your content, as the "<marquee></marquee>" example below shows.
One is approximately equals to 10 pixels. As you can see in the example below, it requires a lot of to make the spaces wide enough.
The drawback of using instead of CSS is that it is very cluttered and messy; however, it is much quicker and easier than having to write CSS definitions.
Sometimes you can't write CSS definitions to fit your goal as in my case below. So you are left to use to accomplish the task.
Nonetheless, be very careful using instead of CSS because in mobile devices it might not display very well, especially if you have lots of .
So use it sparingly is the best way to use it. Don't over-use it!
In my case, it works very well on any mobile devices.
So there you have it! A very neat trick to use!!!
Here is a very simple trick to make your website looks awesome.
You won't see this trick anywhere in the document or tutorials
anywhere but only right here from me.
I use this trick on my own websites on a regular basis.
Here it is:
<div style="width: 700px; height: auto; background-color: #ffdddd;
padding: 5px 5px 5px 5px"><marquee>Content to scroll!</marquee>
</div>
The tag is called "<marquee></marquee>"
This simple tag scrolls continuously any content you put in it!
You can put this "<marquee></marquee>" tag anywhere as a
standalone or inside any HTML elements: <div>, <span>, <p>, etc.
You can also style your <marquee> content, such as
configuring the width and height and background color, etc.
Here is the same code that I use on my website: ZeroNilZilch.COM.
Notice that I embedded the styling code directly in the <marquee></marquee> as
appose to putting it in the <div></div> or other HTML elements.
It is just a personal preference and any HTML elements will work just fine.
As you can see, I had to use lots of to make enough spaces between contents!
The listing of between contents is a continuous line, but here,
it is broken down into multiple lines for displaying purpose!
<marquee bgcolor="white" width="100%" height="50">
<font size="5" color="#00FF99">www.ZeroNilZilch.COM</font>
<font size="5" color="#3333FF">Where the future is already here!</font>
<font size="5" color="#00FFFF">Explore, see the horizon,
open your mind and let your curiosity run wild,
discover, inspire and enrich your learning!!!</font>
<font size="5" color="#3333FF">The engine of your inginuity is limited only to
your imagination!!!</font>
<font size="5" color="#FF66FF">
Welcome to the 21st century and beyond where digital mobile rules!</font>
<font size="5" color="#1883FF">
This website and all of our affiliate sites are mobile-friendly!</font>
<font size="5" color="#00FFFF">
This means that you can use your mobile phones or any portable
small device to surf and shop with us conveniently and securely at all of our
affiliate sites!!!</font>
<font size="5" color="#FF66FF">They're built for the Millenials,
where all things Millenial, the Millenials' way!!</font>
<font size="5" color="#3333FF">Go ahead and fire up your smartphones and load
this website and see if it's mobile-friendly or not!</font>
</marquee>
Here are some more special characters to make your websites appear more useful. Please check this out:
Here is a very simple trick to make your texts appear vertically as well as other text effects that you might find useful. Please check these out:
https://www.w3schools.com/cssref/css3_pr_writing-mode.asp https://www.w3schools.com/css/css_align.asp https://www.w3schools.com/cssref/pr_text_text-decoration.asp https://www.w3schools.com/cssref/css3_pr_transform.asp https://www.w3schools.com/cssref/css3_pr_transition.asp https://www.w3schools.com/cssref/tryit.asp?filename=trycss_zindex
Here is a very simple trick to make your navigation bar works on mobile devices. On desktop it will display the menu items horizontally but on mobile devices, it will display them vertically.
Note that on mobile devices, the menu bar will be cleared all of menu items and a fontawesome fa fa-bars: is used instead in place of the menu items and the fa fa-bars is shown on the menu bar as a button to click.
When a user clicks on the fa fa-bars symbol it opens up the menu items listing the menu items vertically and neatly.
Using NAV tag, you don't need to do any special tricks to make it mobile-friendly: it is already built-in the browser technology.Just list your menu items to make it work on desktop devices as you normally would and the browser technology takes care of the mobile devices display behind the scene for you so that you don't need to do any special tricks:
https://www.w3schools.com/tags/tag_nav.aspThere you have it! A secret way to beautify your website!!!
Here is a very simple trick to make your website mobile-friendly. First of all, this is just a simple trick that is suited to some small situations where CSS is too complicated and too bulky to use. This trick works very well when you have a section of the code needs to handle small mobile devices and another section next to it can be used for desktop devices. For example:
<?php
/** this is a special trick that you'll never see from **/
/** any documentation or tutorials anywhere, period! **/
/** here is the special trick using a combination of PHP and Javascript: **/
echo "<script language='javascript'>
/** you need a space between the echo " and location **/
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&width=\" + screen.width + \"&height=\" + screen.height;\n";
echo "</script>\n";
/** basically, the code above picks out the width and height **/
/** of the device using Javascript screen object and just **/
/** referring to the object's property: width and height! **/
/** very neat and simple! **/
/** the reference to 'location.href' is just reading the url's **/
/** incoming request and picking off the querystring at **/
/** the same time! **/
/** okay, let's see how it works! **/
/** first, you test the size of the device **/
/** in other words, when the browser hits this code above, **/
/** it checks to see what size the device is. **/
/** if it is a desktop device being used to surf this website, **/
/** it will execute the area of the code designed to be used on desktop! **/
/** if it is a mobile device being used to surf this website, **/
/** it will execute the area of the code designed to be used on mobile **/
/** devices **/
/** this is much simpler than having to write CSS definitions **/
/** it works just as good as if you had written a CSS definition to **/
/** do the job! **/
/** as a matter of fact, the groups that wrote the CSS rules to **/
/** make CSS definitions mobile-friendly used this same technique to **/
/** detect the devices to make their CSS rule do the job **/
/** of detecting the various mobile size! **/
/** they called it media definition that looks like this: **/
@media (max-width: 480px)
{
.nav-collapse
{
-webkit-transform: translate3d(0, 0, 0);
}
.page-header h1 small
{
display: block;
line-height: 20px;
}
}
/** but first, you need to test if the browser can read **/
/** the dimensions of the device being used to surf the webpage! **/
/** all browsers returns a width and height of the device being **/
/** used every time it loads the webpage! **/
/** but we need to use a special trick that you'll never see from **/
/** any documentation or tutorials anywhere, period! **/
/** here is a special trick using a combination of PHP and Javascript: **/
<?php
if (isset($_GET['width']) AND isset($_GET['height']))
{
global $width;
global $height;
// grab the geometry variables
$width = $_GET['width'];
$height = $_GET['height'];
if ($width > 600)
{
// desktop device! prepare code to be used on desktop!
?>
<!-- left column -->
<div class="mobile-col m3">
<!-- display left column content for desktop! -->
</div>
<!-- end left column -->
<!-- middle column -->
<div class="mobile-col m7">
<!-- display middle column content for desktop! -->
</div>
<!-- end middle column -->
<!-- right column -->
<div class="mobile-col m2">
<!-- display right column content for desktop! -->
</div>
<!-- end right column -->
<?php
} // end if $width > 600
else
{
// mobile devices! prepare code to be used on mobile devices!
// notice that inside this mobile section, you still need to
// use CSS to style the content to be mobile-friendly!
// I told you earlier that this simple trick doesn't do all of
// your mobile-friendly works! it does for certain situations only!
// you can use both this trick and CSS definitions to your advantage!
?>
<!-- left column -->
<div class="mobile-col m3">
<!-- display left column content for desktop! -->
</div>
<!-- end left column -->
<!-- middle column -->
<div class="mobile-col m7">
<!-- display middle column content for desktop! -->
</div>
<!-- end middle column -->
<!-- right column -->
<div class="mobile-col m2">
<!-- display right column content for desktop! -->
</div>
<!-- end right column -->
<?php
} // end else if $width > 600
} // end if (isset($_GET['width']) AND isset($_GET['height']))
else
{
// pass the geometry variables (preserve the original query string
echo "<script language='javascript'>\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&width=\" + screen.width + \"&height=\" + screen.height;\n";
echo "</script>\n";
// if for some reasons that the browser fails to grab the dimensions
// it will come here and you can handle that case accordingly!
// that situation is very rare! this code above always returns
// the dimensions!
// desktop device! prepare code to be used on desktop!
?>
<!-- left column -->
<div class="mobile-col m3">
<!-- display left column content for desktop! -->
</div>
<!-- end left column --<
<!-- middle column -->
<div class="mobile-col m7">
<!-- display middle column content for desktop! -->
</div>
<!-- end middle column -->
<!-- right column -->
<div class="mobile-col m2">
<!-- display right column content for desktop! -->
</div>
<!-- end right column -->
<?php
}
?>
There you have it!
A secret way to beautify your website by making it mobile-friendly!!!
Here is an interesting topic that you might find very useful: Tracking Visitors of Your Website
If you want to use the professionally-made tools and here are a few to choose from:
Paid Web Analytics Tools For Tracking Your Visitors
Web Analytics Tools For Tracking Your Visitors
10 Web Analytics Tools For Tracking Your Visitors
Here is my "barebone" simple code to track your visitors visiting on the index.php front page of your website. Any time a visitor visits your website, which is primarily being visited on the index.php front page, it tracks that person as one visit. If that person returns to visit your website again on another occassion on another session, it accounts for that visit as another one visit as well.
In other words, it logs each visit by a person as one visit no matter how many pages or area a visitor is visiting because this "barebone" simple code is designed to track only one page, which is the index.php front page. When a person continues to visit other pages on your website it does not account for those visits.
When a person leaves the website entirely and comes back to visit the website again, it again will log that person as one unique visit without differentiating the visit as a return visit. It keeps doing this for all other visitors as well.
It tallies all of the visits from all visitors [new or old visitors] that enter the website on every session to account for the website traffic. The total count of the page hits does not account for the return visits by the same person.
You can make improvement to this code as well or use it "AS IS" without any modification.
First of all, you will need to create a MySQL database to store all of your page hits.
To track your website traffic, just put all of the below code in a PHP file (perhaps, name it as pagehit.php) and then include this file name (pagehit.php) at the top of your index.php front page. See an example index.php front page later.
Remember that the following code is written to log only one page, which is assumed to be an index.php front page. So put the whole code below at the top of your index.php front page.
However, you can track page hits on every page of your website as well -- not just the index.php front page.
To count page hits on all of your website pages, just include this file name (pagehit.php) in every one of your pages. It will log different querystrings for different pages.
So the key thing to come away with this code (below) is that you can place the below code at the top of every page of your website if you want to track each page. However, it will distort your total page hits because a visitor may visits all of your pages and since each of your page contains a code to capture the page hit, the total page hit will be larger than it should be.
Let's put it this way: You want to track your website's unique traffic but if a visitor visits all of your pages or just some of your pages, the page hits will not reflect the true website's unique traffic. That's why this code below was designed to track only the index.php front page so that it accurately tracks the website's unique traffic.
So if you put the below code at the top of every page on your website it will just add all of the page hits together from all of your pages, including the index.php front page. In other words, it combines all of the page hits from all of your pages as one total and this total does not reflect the true unique traffic of the site.
So if you want to know which page got how many hits, you'll have to modify the code slightly because the code below just lump all of the various page hits together as one total, and this total includes the hits on the index.php front page, too.
Notice that you can either put the following code in a PHP file (pagehit.php) and include it like [include("pagehit.php")] in every page of your website OR just copy and paste the entire code and put it at the top of every page of your website and it will work just fine.
File: pagehit.php
<?php
/**
* a function to count how many times visitors visit a particular page
*
* you can call this function by passing a page file to it
*
* see at the bottom of this function to see how it is being called
*
* notice that argument $page can be any page on your website, but
* the database code just add all of the page hits together regardless
* of what page or pages you pass to it!
*
* this is where you can modify the database code slightly to store
* the different page hits individually! it's up to you to modify it!
*
* if you don't really care which page gets the most hit and only
* care about the whole website's total hit, then there is no need to
* modify this code! just use it "AS IS" and include the file
* pagehit.php at the top of the index.php front page and don't
* include this file in any of your pages because the index.php file
* is the only file we're tracking! nothing else!
*/
public function pageCounter($page, $referer)
{
// you might want to pass these connection parameters
// from external source instead of embedding them like here!
$hostingserver = 'root';
$databaseName = 'your_database_name';
$username = ''; // your database username
$password = ''; // your database password
// try to create a PDO connection instance
try
{
$conn = new PDO("mysql:host=$hostingserver;dbname=$databaseName",
$username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
echo 'Cannot connect to the PDO database. ' . $e->getMessage();
}
// now try to create a table named pagecounter if it
// doesn't already exist in the database
// if it already exists in the database, it will skip this try/catch blocks!
// in other words, it won't create a table named `pagecounter` because
// it already exists in the database!
// however, it will continue executing all codes following the try/catch
// blocks!
// FYI:
// I've found that for some shared hosting's PDO engine doesn't
// recorgnize this statement:
// 'CREATE TABLE IF NOT EXISTS'
// to solve that problem, remove the below statement and create the table
// manually using PHPmyAdmin or some other means!
// so you don't actually need to test this condition (below) every time a
// page is hit! in other words, you don't need to check if the table
// exists or not, because you already know that a table already have been
// created; and therefore, there is no need to use the condition
// code below!
// just remove the create table condition below and make sure your table
// have been created already and it will work just fine!
try
{
$sql = $conn->prepare("CREATE TABLE IF NOT EXISTS `pagecounter`
(
`id` int(25) NOT NULL auto_increment,
`page_name` varchar(255) NOT NULL default '',
`referer` varchar(255) NULL default '',
`page_hit` int(25) NOT NULL default '0',
`date_time` datetime NOT NULL default
CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) TYPE=MyISAM"
);
// execute the query to create the table
$sql->execute();
}
catch (PDOException $e)
{
echo 'Cannot create table pagecounter. ' . $e->getMessage();
}
// after creating the table, it's time to insert new page hits
// but first, check to see if there are any page hits already stored
// in the database
$query = $conn->prepare("SELECT * FROM pagecounter
WHERE page_name = :page");
$result = $query->execute(['page' => $page]);
// check to see if there are any page hits already stored
// in the database
if ($result)
{
// yes, there are page hits already stored in the
// database!
$result->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $result->fetch())
{
// so just add the new page hit to the total
$counter = $row['page_hit'] + 1;
}
// after adding a new page hit to the total,
// we need to update the total page hits and as well as
// updating the rest of the record, too!
$update = $conn->prepare("UPDATE pagecounter
SET page_name = :page,
referer = :referer,
page_hit = :counter");
$update->execute([':page' => $page,
':referer' => $referer,
':counter' => $counter
]
);
}
else
{
// this must be for the first page hit!
// there are no page hit stored in the database,
// so we need to store the first page hit in the database
$stmt = $conn->prepare("INSERT INTO pagecounter
VALUES (?, ?, ?)"
);
$stmt->execute([
'page_name' => $page,
'referer' => $referer,
// since there are no page hits stored in the
// database, so it must be the first time,
// and therefore, 'page_hit' is set to 1
'page_hit' => '1'
]
);
// if you observe the create table code definition
// and the insert table code above, you'll notice that
// there are 5 table fields in the create table code
// while only 3 fields (page_name, referer, and page_hit) are
// performed in the insert/update table code above.
// if you look closely in the create table definition
// you'll notice that the 'id' field contains the
// "auto_increment" clause that MySQL uses to increment
// this 'id' automatically starting with number 1 and
// increments it by 1 each time you insert a row of record.
// therefore, the 'id' field is not directly handled by
// programmers -- it is handled by MySQL automatically.
// likewise, the `date_time` field is not directly handled by
// programmers, either -- it is handled by MySQL automatically,
// because it was declared in the definition to use a
// 'default' date time value, generating a date and time
// automatically every time an insert or an update operation
// is taking place.
// the function CURRENT_TIMESTAMP generates the date and time
// automatically!
// so it looks like this:
// `date_time` datetime NOT NULL default CURRENT_TIMESTAMP
// self-explanatory!
// now on to the code flow:
// since this is the first time a visitor saw this
// page, we initialize the page to one hit!
// the next time any visitor visits this page it
// will not come here in the "else" condition because
// $result contains some value(s) for the tracking page!
$counter = 1;
}
// return the result of the query back to the caller!
// this is the number of times the page has been hit by visitors!
return $counter;
} // end function pageCounter($page, $referer)
/**
* now that the function has been written, we can call that function
* from anywhere!
*
* to call that function, you have to include the following snippet
* of code!
*
* put the following code at the top of every page you want to track!
*/
// HTTP headers
// every time the Web runs it fires off the HTTP protocol and PHP has a
// a built-in variable called $_SERVER to grab all of the HTTP headers.
// The superglobal array variable $_SERVER has 32 values, i.e.,
// $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'],
// $_SERVER['QUERY_STRING'], $_SERVER['SCRIPT_NAME'], $_SERVER['PHP_SELF'],
// $_SERVER['IP_ADDRESS'], $_SERVER['DNT'], etc.
// and you can view these values by running in your view (index.php)
// page or in any page output code like this:
// print_r($_SERVER);
// here, we grab the page's url using the HTTP protocol,
// particularly the built-in (superglobal) array variable $_SERVER.
// in here, we're just grabbing those HTTP headers, such as the URI or URL,
// including the querystrings. that's what the following code is doing!
// the $_SERVER['PHP_SELF'] code is to refer to the current file itself!
// so if you put $_SERVER['PHP_SELF'] inside a file called index.php, it
// will run that file!
// as for $_SERVER['SERVER_NAME'] is to grab the server name, i.e.,
// example.com.
// as for $_SERVER['HTTP_REFERER'] is to grab the url that the visitor
// just came from!
// for example, if a visitor came to your website from another website
// called http://www.example.com, $_SERVER['HTTP_REFERER'] returns
// http://www.example.com
// as for $_SERVER['QUERY_STRING'] is to grab the url's querystring, the
// string after the '?', i.e.,
// www.example.com/?arg1=value1&arg2=value2&arg3=value3
// so this will look something like these:
// www.example.com/index.php?arg1=value1&arg2=value2&arg3=value3
// www.example.com/catalog.php?arg1=value1&arg2=value2&arg3=value3
// www.example.com/affiliate.php?arg1=value1&arg2=value2&arg3=value3
// www.example.com/mypage.php?arg1=value1&arg2=value2&arg3=value3
/**
* here are some useful items you might find useful:
*
* $visitor_hour = date("h");
* $visitor_minute = date("i");
* $visitor_day = date("d");
* $visitor_month = date("m");
* $visitor_year = date("y");
*/
$self_url = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?' .
$_SERVER['QUERY_STRING'];
// grab the url of the visitor's last link!
$referer = $_SERVER['HTTP_REFERER'];
// we call pageCounter() and getting a page hit instantly
$page_hit = pageCounter($self_url, $referer);
/**
* now that we have a page hit we can do whatever we want, such as
* display it somewhere on the same page. how you use this page hit
* is up to you, but here we just echoing out to the browser to
* display the page hit on the same page!
*/
echo $page_hit;
/**
* what if you want to put the display of the page hit somewhere
* on your website beside the default front index.php page?
*
* in other words, you want to put a hit counter in a different page
* other than the front index.php.
*
* in that case, you have to query the database using the code
* similar to the following. see a seperate index.php example below.
*
* you need to put this code at the very top of your xxx.php page!
*
* // try to create a PDO connection instance
* try
* {
* $conn = new PDO("mysql:host=$hostingserver;dbname=$databaseName",
* $username, $password);
* $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
* }
* catch (PDOException $e)
* {
* echo 'Cannot connect to the PDO database. ' . $e->getMessage();
* }
*
* $query = $conn->prepare("SELECT * FROM pagecounter
* WHERE page_name = :page");
*
* $result = $query->execute('page' => $page);
*
* if ($result)
* {
* $result->setFetchMode(PDO::FETCH_ASSOC);
* while ($row = $result->fetch())
* {
* $counter = $row['page_hit'] + 1;
* }
* }
*
* and then you can basically display the hit page anywhere on
* your xxx.php. for example:
*
* <p>Total visits: <?=$counter?>
*
* see the "barebone" index.php page below as an example!
*/
?>
The example above can be used to display in the "barebone" index.php front page as well.
Here is a "barebone" index.php front page example to show how to include the pagehit.php file at the top of your index.php front page.
File: index.php
?<php
// here, assuming you name the whole code above as pagehit.php
// this is it! just one line!
// very simple to include a tracking script on
// your index.php front page!
// don't forget to put the file pagehit.php at the same level
// in directory as your index.php
include(pagehit.php);
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>My Home Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="language" content="en" >
<link href="./asset/44ab1983/css/style.css" rel="stylesheet">
<script src="./asset/16eb9947/jquery.js"></script>
<style>
html,
body
{
width: 100%;
height: 100%;
background-color: #e6e6ff;
}
#product-item
{
background-color: white;
padding-left: 10px;
padding-right: 10px;
}
</style>
<script type="text/javascript">
$(document).ready(function()
{
public function example(arg)
{
// function code
}
});
</script>
</head>
<body>
<div>
content of the div
</div>
<div>
<table>
<tr>
<td>
td content
</td>
</tr>
</table>
</div>
<div>
content of the div
<a href="#">link</a>
</div>
</body>
</html>
There you have it! An easy way to track your website's visitors!!!
Now that you've got your website with all the bells and whistles, you can migrate it to your live server to make your website live online for your visitors all over the world to see.
There are plenty of web hosting providers out there: both for paid hosting and for free hosting. Just Google the term "free web hosting" and it will give you a lot of results to choose from.
Here is one that I found on the Internet, the one that I use on one of my websites: https://webfreehosting.net/
As with all free web hostings, there are certain things you can and can't do, such as you can't incorporating your payment application to do ecommerce transactions. To be able to do ecommerce transactions, you'll have to subscribe to their paid hosting service that normally costs about $2.99 per month.
For the free basic web hosting plan, you are limited to certain bandwidth as well. For example, according to the basic free plan (advertised as of June 2021), you're allowed only 5 GB of traffic usage per month. If your website generates traffic usage higher than 5 GB per month they will suspend your website for the remainding time for that particular month once your website reaches 5 GB.
Your website will come back online live at the beginning of the next month. Here is what a notification of the suspension look like if your website happens to generate usage traffic higher than the allowable 5 GB (as was the case for one of my websites called www.PostalJobHotline.COM which got the below suspension notification):
Warning: Account Suspended Due to Over-Traffic!
Your account has been temporarily suspended, because you have reached 5.16 GiB of traffic usage and your monthly allowance is 5 GiB. The traffic counter is reset at the end of the month and your account will be restored automatically. If you do not wish to wait that long and want to have your account and websites working please go to Buy Services Upgrade Services section and upgrade to a hosting plan with higher monthly traffic allowance.
So if for some particular month -- especially late in the month -- and you happen to go to one of my websites and you can't access it, it's probably it is being suspended due to over-traffic usage limit. Now you know why sometimes my websites are offline because of the suspension due to over-traffic usage limit.
Not only that, even if you have a paid hosting plan with them and if your website receives a lot of traffic, this hosting provider throttles your bandwidth to slow down your visitors visiting your website, making your website to load very slowly.
An example of that is my website ZeroNilZilch.COM, which receives very heavy traffic, and as a result, this hosting provider throttles my bandwidth, making it very slow to load. So much for a paid hosting plan, huh? Where is the benefit?
You may have already noticed that the website is very slow to load. This is because my website receives very very heavy traffic and this hosting provider throttles my bandwidth traffic.
So please be patience with my website when surfing my website and please keep visiting my website regularly when you need to. I would love to have you all continue making use of the resources in my website on a regular basis.
Thanks!!!
If you compare ZeroNilZilch.COM with the rest of my websites, say, Noon2Noon.COM, or Rainbow180.COM, or PostalJobHotline.COM, ZeroNilZilch.COM takes a long time to load while the others are very fast to load. This is due to this hosting provider throttles my loading speed because of ZeroNilZilch.COM generating very very heavy traffic.
As you can see, even when I follow their policy very religiously and not even anywhere close to breaking their policy, they still impose limits on my website, something that I'm not very happy about. So this is the only one factor that I'm not happy about this hosting provider.
So please read their policy. Also, you need to abide by their policy on all other aspects of the "free plan" to avoid being shut down. So make sure you read their policy on what you can do and on what you "CAN'T" do.
I hope you take this warning seriously because once you're shut down, you can't get another account with the same host provider. You'll have to find another hosting provider.
All hosting providers have policy that they enforce very strictly. So don't loose your hosting account with this hosting that I mentioned above, because it is one of the best hosting providers out there, albeit, they impose bandwidth limits when your website receives very heavy traffic.
I don't know if other shared hostings do this or not. Anyhow, please be mindful of this scenario.
So good luck and have fun with your website, albeit be mindful of the policies placed on your hosting plan.
Here is a secret that no one will tell you about this hosting provider mentioned above, but I will: You can actually signup for many hosting accounts with this hosting provider so that you can host as many (of your) websites as you want.
Yes, that is right; you can have your websites hosted by this hosting provider and it is perfectly legal and they won't ban you for hosting multiple websites on their platform. Yes, that is correct! You can host multiple websites on their platform! I repeat: You can host as many websites as you want on their plaform.
All you have to do is signup each account for each of your websites using a unique email address and it will let you signup for multiple accounts to host multiple websites.
My suggestion for you is to create multiple email accounts, say, with Gmail.COM or with any other email services and using those email addresses to signup hosting accounts with this hosting provider to host all of your websites.
Yahoo Mail is also one of the best emai service providers out there and it on par with Gmail service.
I, myself, use both Gmail and Yahoo Mail for my emails needs. I singed up multiple email accounts with both and the best part is that you can signup for an ulimited email accounts and also you can use the same personal information for all accounts as well, but the only requirement is that you need to use unique username, password, and of course, unique email address for each account.
For example, I currently have four Gmail accounts and three Yahoo Mail accounts and I used those email addresses that I signed up to signup for the free webhoting from the web hosting service provider mentioned above.
Remember that one email address is only good for one hosting account to host one website. So if you have multiple websites (as I do), you need to have multiple email addresses so that you can use those email addresses to signup hosting accounts with this hosting provider.
One email address is only good for one website.
You can use (your) same name and same address and the same other information as well.
You don't have to use different name and different other information.
Email address, username, password are the only ones that need to be unique for each account.
One Last Warning:
Please DO NOT abuse your free hosting priviledges. In other words, please read their 'Users Policies' carefully and obey their rules and guidelines.
Just because it is free and you can signup for multiple accounts, it doesn't mean that you can do anything you feel like doing.
So enjoy your multiple hosting accounts for your multiple websites, but be mindful of their rules and guidelines and DO NOT abuse your priviledges.
There you have it!
A secret that no one will tell you about it!!!
But I am telling you that!!!
So good luck and have fun with your websites, albeit be mindful of the policies placed on your hosting plans.
Once you'd signup an account with the above mentioned webhosting service provider, you can login to your account and the dashboard/webspace looks like the following:
On the left side is where it lists your account detail that looks like the following:
As you can see in the dashboard area or webspace area, you have several options to choose to go into more specific tasks. It shows all kinds of options for you to choose.
For example, when you click on an FTP Manager, it takes you to an FTP manager area where you can setup/create FTP accounts.
From there, you can fill out and supplying the various required FTP account information.
After creating an FTP account, now you're ready to upload your website files to your FTP account.
You will need these FTP account information to be used with your FileZilla application to transfer your files to and from your local computer to your FTP account.
See my other tutorial called Introduction to FileZilla.
Next, you need to create database(s) by clicking on the Database Manager and fill out the appropriate information. You will need these information to use with your database "PDO" connection.
See my other tutorial called Introduction to PDO.
At this point, you're done with creating FTP and Database accounts and presumably all your website files have been uploaded to your FTP account and your database tables and content have been created and setup and ready to go.
Next, you need to setup your domain. Look in your dashboard area for a topic called Domain Manager (similar to the one shown in the above illustration under topic called Website Manager). Click on that topic to go to setup your domain and it opens up a domain creation view that looks like the following:
In the above area where you can setup/create your domain accounts by supplying the necessary information.
There are several options to choose from depending on your actual situation. You can actually buy your own domain from this hosting provider on the spot by clicking on 'register a domain'. You can also transfer your domain to this hosting provider if you had registered it with some other domain registrars.
Either way, you're good to go with this hosting provider.
Personally, I recommend you to register your domain with other hosting/domain service providers that can offer you cheap domains. There are plenty of cheap domain service providers out there and one that I use personally is called https://www.namesilo.com/
If you're using domain from other domain service providers, just type the name of your domain in the box under: 'Host an existing Domain', for example: myfirstsite.com. And click on "Host Domain" button. Don't forget to put the "DOT" suffix name after your domain as shown in the example. This can be .com, .net. .org, etc.
If you're using a domain from other domain service providers, make sure that the domain is fully active, otherwise, this hosting is not able to detect your domain from the central server of the World Wide Web Consortium who actually is maintaining the domains as a central location.
The domain service providers are just third parties sellers selling domains from the main body organization called the World Wide Web Consortium.
What really is going on is that this hosting provider checks to see if the domain name that you entered on the input box is registered under your name listed on the World Wide Web Consortium database. The World Wide Web Consortium maintains all domain names in its database.
If the domain you entered is found in the WWWC database and it is registered in your name, then this hosting provider will host your domain in their web server. Otherwise, a message stating the reason as to why your domain is denied hosting.
After that, it should give you some sort of result at the bottom of your domain space if it is hosted successfully with this hosting provider.
In the result that you just created and hosted successfully, look at the heading at the far right side that says "Settings" and click on that topic. It should slides down to reveal more content. Now click on the topic: "DSN" (stands for 'Domain Name Server') and it should slides down further to reveal more content on that topic.
There are lots of options for you to choose, but for beginners, you only need to be concern with the topic called "NS".
Next, look under the heading called "Type" on the left side and scan down to find "NS" which stands for 'Name Server', or short for 'Domain Name Server'.
You need to copy this domain name server (address) so that you can use it to link your domain that you had registered with other domain service provider to your hosting account with this hosting service provider.
In a simplier way of saying is that, this domain name address is used to link your domain name that is residing in your third party domain registrar (or more specifically, residing in the WWWC database) to this web hosting provider. Your third party domain registrar needs this information to link the two servers together.
For example, if you had registered your domain name with other companies, (i.e., namesilo.com), you need to copy this 'Name Server' from this hosting provider and take it to your domain name registrar (namesilo.com) to link it to your domain name stored in the database in the WWWC.
This 'Name Server' will link to your domain name stored in the WWWC database. But you have to link it through your domain registrar.
Once you have the domain name server address (from this hosting provider), you need to go back to your domain service provider that you had registered and had an account with and login to that account so that you can supply this "NS" information to that domain registrar.
In your (third party) domain service provider/registrar's dashboard space, there should be an option that says "Domain Manager" and you need to navigate to that domain manager space and look for some sort of topic called "domain service name entry" or similar to that nature and then supply the "NS" information to it accordingly.
Hint: In your third party domain service registrar, look in the "Domain Manager" and click on one of the options listed on your particular domain. Maybe try clicking on the name of your domain and see what options it reveals.
Different domain service providers have slightly different look and feel, but all of them should have something in common, and that is, a box for you to enter the "NS".
Here is an example of domain entries:
Name Server 1: ns1.example.com
Name Server 2: ns2.example.com
Name Server 3: ns3.example.com
Name Server 4: ns4.example.com
Name Server 5: ns5.example.com
Each of these domain name servers represents one independence server that the company owns. Web hosting providers often have multiple servers so that if one goes down there are some backup servers ready to take over.
For example, this (fake) web hosting company called www.example.com has five servers: ns1, ns2, ns3, ns4, ns5.
As you can see above, there are several domain name servers that you need to enter, but for most hosting providers like the free web hosting service provider that I mentioned above, you only need to supply only two "NS" entries are enough.
In actuality, you're really using only one domain name server: ns1. The second one is just a backup in case the first is down or having problem. These days, servers are very reliable and one server is enough. So take two domain servers to your domain registrar (usually the first two: ns1 and ns2).
Once you've entered the "NS" information and submitted, it will take about 12 hours to take effect, although some domain providers take longer or shorter.
Meanwhile, after about an hour or so after you've submitted your "NS" information, you can try to load your website to see if it's effective or not. I've found that with most domain service providers, it only takes about one hour to take effect and not more. Try it after an hour of the entry and see if it is effective.
At this point, everything has been covered to enable you beginning website developers to able to create websites and host them in a live server. You can keep making improvements to your websites as they get more sophisticated.
There you have it! Have fun with your websites!
<?php class Foo{ public test($x) { if ($x == 1){ // do something with $x }elseif ($x == 2){ // do something with $x again }elseif ($x == 3){ // do something with $x again }else{ // do nothing with $x } } private getFoo(){ for ($i = 1; $i < 10; ++i){ // do something with $i } } } ?>
<?php class Foo { private $arr; public function config() { return [ 'id' => 'app', 'basePath' => dirname(__DIR__), 'component' => [ 'request' => [ 'csrf' => 'csrf-app', ], 'user' => [ 'identity' => 'app\model\User', 'autoLogin' => true, 'cookie' => [ 'name' => 'id-app', 'httpOnly' => true ], 'error' => [ 'action' => 'site/error', ], ], ], ]; } // end config() public function example($arg1 = null, $arg2 = null) { if (!empty($arg1)) { // do something with $arg1 foreach ($arg1 as $item) { // do something with $item try { switch ($item) { case 1: // do something if ($something) { for ($i = 0; $i < $something; $i++) { $dosomething[$i] = getSomething(); } } elseif ($otherThing) { foreach ($otherThing) { try { $doOtherThing = getOtherthing(); } catch (Exception $e) { // doOtherThing with $e; } catch (OtherException $o) { // doOtherThing with $o } } // end foreach } // end elseif ($something) break; case 2: // do something break; case 3: // do something break; default: // do something break; } // end switch } // end try catch (Exception $e) { // Error! Do something with the error $e } } // end foreach } // end if $arg1 is not empty elseif ($arg2 != null) { // do ... while and for() loops $test = false; do { for ($i = 0; $i < count($arg2); ++$i) { if ($arg2[$i] == 1) { $test = true; break; } } // end for() } // end do while ($test == false); } // end elseif else { // do nothing return ''; } $connect = ''; $attempt = 3; while (!$connect AND $attempt > 0) { $authConn->connect(); $connect = $authConn->isConnect(); $attempt = $attempt - 1; } } // end example() } // end class Foo ?>
<?php class Foo { public addValue($x, $y) { // method body } // end addValue() private getFoo() { // method body } // end getFoo() } // end class Foo ?> Notice the comments: // end addValue(), // end getFoo(), // end class Foo
<?php class Foo { if ($expr1) { // lengthy multiple statements code block // lengthy multiple statements code block // lengthy multiple statements code block } // end if ($expr1) elseif ($expr2) { // lengthy multiple statements code block // lengthy multiple statements code block // lengthy multiple statements code block } // end elseif ($expr2) else { // lengthy multiple statements code block // lengthy multiple statements code block // lengthy multiple statements code block } // end else if ($expr2) try { // lengthy multiple statements code block // lengthy multiple statements code block // lengthy multiple statements code block // lengthy multiple statements code block } // end try block catch (Exception $e) { // lengthy multiple statements code block } // end Exception $e catch (OtherException $o) { // lengthy multiple statements code block } // end OtherException $o } // end class Foo ?> Notice the comments: // end if ($expr1), // end elseif ($expr2), // end else if ($expr2) // end try block, // end Exception $e, // end OtherException $o // end class Foo
[...elements...]
is used instead of the regular long form array(...elements...).
And (shorthand) arrays used in the configurations can optionally contain a comma (",") as well at the end of the array element list. As examples, the below configurations contain a comma following the last array element [particularly 'charset => utf8' for shorthand array] even though there isn't another array element following it.
As a matter of fact, both regular arrays and shorthand arrays can contain a comma (",") at the end of the array element list. This is legal (for both) and you can choose to put it there or take it out and it is perfectly fine. It's not a requirement to have a comma at the end of the last array element. So it's up to your personal preference.
However, this coding standard strongly recommends putting a comma after all array elements because it avoids bugs. The reason that it is legal to have a comma after the last array element is to speed up coding process and avoid bugs. So it is strongly suggested that you put a comma after the last array element to avoid bugs.
Here is a snippet of code using the regular array:
$requirement = array(
array(
'name' => 'PHP Some Extension',
'mandatory' => true,
'condition' => extension_loaded('some_extension'),
'by' => 'Some application feature',
// notice the comma after this last array element!
'memo' => 'PHP extension "some_extension" required',
), // <== notice the comma! this is perfectly legal!
);
In the following, a configuration is used to create and initialize a database connection. Notice the comma following the array element 'charset => utf8' even though there isn't another array element following it:
$config = [
'class' => 'core\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
'username' => 'root',
'password' => '',
'charset' => 'utf8', // <== notice the the comma! it's perfectly legal!
];
$db = core::createObject($config);
If you look at the example preview earlier [in the function config()], you'll see shorthand arrays are being used and all last elements of the arrays have a comma after each of the last element of the arrays. So it is definitely recommended that shorthand arrays and a comma on the last element of the array are being used -- on your own programming chores -- because it is much cleaner and easier to visualize, and most importantly, it speeds up your application development by eliminating bugs and unnecessary syntax corrections.
$a = $b + $c; // add b to c Do not do this: $a=$b+$c; //add b to c if ($b == $c) Do not do this: if($b==$c) Do not do this: for($i=0;$i<10;$i++) Do this instead: for ($i = 0; $i < 10; $i++)
class Example { }That looks very good, but on longer reserved/keywords like public, private, protected, static, etc., it looks awful. For examples:
public class Example { } private class Example { } protected class Example { } static class Example { } Or for conditional structures: if (condition) { } else { } elseif { } foreach { }As you can see, indenting four spaces for all code structures, [although very uniformed], is a bad idea, and it looks weird visually and logically. That's why I chose to indent the code according to the length of the reserved keyword.
class Example { private $myVar; public myMethod($x) { // ... code return $x; } // ... more class code here! }Nowaday, the trend is leaving the legacy style behind and more and more programmers are adopting new modern style of coding and my coding convention is a byproduct of the new trend. So do these instead:
<?php class Foo { /** * class body declaration. * notice the four spaces indentation of the class' opening "{" and * the five spaces indentation of the method declaration: public. * notice also that the opening/closing parentheses are aligned vertically at the * same level, and all respective code body are inside the parentheses. * it looks very clean and easy to follow the logic of the code flow. */ public $arr = array(); private $dbConnection; public addValue($x, $y) { // method body // notice that the indentation and placement of the opening "{" and // closing "}" directly leveled with the last letter of its keyword. } private getFoo() { // method body // notice that the indentation and placement of the opening "{" and // closing "}" directly leveled with the last letter of its keyword. } protected getBar() { // method body // notice that the indentation and placement of the opening "{" and // closing "}" directly leveled with the last letter of its keyword. } // this is ok, too, and is preferred, indent five spaces to align with // 'public' which is the most commonly use visibility clause protected setFoo($x) { // method body } public addFoo() { // method body } // this is ok abstract protected function zeroBar(); { // method body } // this is ok, too, indent five spaces to align with 'public' which is // the most commonly use visibility clause abstract arrayHelper() { // code body here for this abstract method } public static function bar() { // method body } // this is ok, too private static function bar() { // method body } // this is ok, too, indent five spaces private static function bar() { // method body } final public static function bar() { // method body } // same as above final private static function bar() { // method body } static function bar() { // method body } // this is ok, too function bar() { // method body } // this is ok, too, indent five spaces to align with 'public' function bar() { // method body } // this is ok, too, because it has at least five spaces indented for body code function bar() { // code body. // notice the placing of "{}" at the same level as the method declaration. // notice also the indented five spaces for coding statements // starting position // ..... } } // end class body ?>
trait ArrayHelper { // main body code of a trait }CSS: For CSS and other languages (such as Javascript, Java, C#, C/C++, etc.) do follow the guideline outlined in this coding standard and follow a five-space rule to align with 'public' visibility clause. For examples:
<style> html, body { width: 100%; height: 100%; background-color: #e6e6ff; } #product-item { background-color: white; padding-left: 10px; padding-right: 10px; } div .some-selector { background-color: white; width: 400px; height: 200px; } .nav li > form > button.logout { padding: 15px; border: none; } a.asc:after, a.desc:after { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: normal; line-height: 1; padding-left: 5px; } a.asc:after { content: "\e151"; } a.desc:after { content: "\e152"; } </style> <script type="text/javascript"> $(document).ready(function() { public function example(arg) { // function code } // this is ok, too function example(arg) { // function code } // this ok, too, to align with 'public' function example(arg) { // function code } // this ok, too static public function example(arg) { // function code } }); </script>
<!DOCTYPE html> <html lang="en-US"> <head> <title>Untitled</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="language" content="en" > <link href="./asset/44ab1983/css/style.css" rel="stylesheet"> <script src="./asset/16eb9947/jquery.js"></script> <style> html, body { width: 100%; height: 100%; background-color: #e6e6ff; } #product-item { background-color: white; padding-left: 10px; padding-right: 10px; } </style> <script type="text/javascript"> $(document).ready(function() { public function example(arg) { // function code } }); </script> </head> <body> <div> content of the div </div> <div> <table> <tr> <td> td content </td> </tr> </table> </div> <div> content of the div <a href="#">link</a> </div> </body> </html>
<?php if ($expr1) { // single statement block. notice the use of braces even though it is not required! } elseif ($expr2) { // elseif code block. single statement block } elseif ($expr3) { // multiple statements code block // multiple statements code block // multiple statements code block } else { // else single statement block code block }
<?php switch ($expr) { case 0: echo 'First case, with a break'; break; case 1: echo 'Second case, which falls through'; // no break case 2: case 3: case 4: echo 'Third case, return instead of break'; return; default: echo 'Default case'; break; }
<?php while ($expr) { // structure of code block }
<?php do { // structure of code block; } while ($expr);
<?php do { // structure of code block; } while ($expr);
<?php for ($i = 0; $i < 10; $i++) { // for code block }
<?php foreach ($iterable as $key => $value) { // foreach code block }
<?php try { // try code block } catch (FirstExceptionType $e) { // catch code block } catch (OtherExceptionType $e) { // catch code block }
<?php $closureWithArg = function($arg1, $arg2) { // body };
<?php $longArg_noVar = function( $longArgument, $longerArgument, $muchLongerArgument ) { // code body }; $noArg_longVar = function() use( /* notice naming variables using enumerated variables, */ /* although $longVar1 is fine */ $longVar1, /* notice naming variables using enumerated variables, */ /* although $longVar2 is fine */ $longerVar2, /* notice naming variables using enumerated variables, */ /* although $longVar3 is fine */ $muchLongerVar3 ) { // code body }; $longArg_longVar = function( $longArgument, $longerArgument, $muchLongerArgument ) use( // readability: indents some spaces $longVar1, $longerVar2, $muchLongerVar3 ) { // code body }; // this is ok too $longArg_shortVar = function( $longArgument, $longerArgument, $muchLongerArgument ) use($var1) { // code body }; // this is ok, too $shortArg_longVar = function($arg) use( $longVar1, $longerVar2, $muchLongerVar3 ) { // code body };
<?php $foo->bar( $arg1, function($arg2) use($var1) { // code body }, $arg3 );
<?php // PHP 5.3 and later: namespace Vendor\Model; class Foo { // code block }
<?php // PHP 5.2.x and earlier: class Vendor_Model_Foo { // code block }
<?php namespace Vendor\Model; class Foo { const VERSION = '1.0'; const DATE_APPROVED = '2012-06-01'; }
<?php namespace Vendor\Package; use FooInterface; use BarClass as Bar; use OtherVendor\OtherPackage\BazClass; class Foo extends Bar implements FooInterface { public function sampleFunction($a, $b = null) { if ($a === $b) { bar(); } elseif ($a > $b) { $foo->bar($arg1); } else { BazClass::bar($arg2, $arg3); } } final public static function bar() { // method body } }
Both class and object have the same meaning and both achieve the same purpose but differ only in the way they're implemented and used.
A class consists of constant variables, properties, and methods. Those are the three basic attributes of a class. That's all a class is: it has three attributes -- a very simple concept and yet very powerful.
Consider the following class definition:
<?php
class MyClass
{
/**
* 1st attribute of the class MyClass:
*
* the purpose of the 1st attribute of the class is to store content values that are
* constant and can't change its values during the lifecycle of the application
*
* as you can see below, the constant variables (declared in uppercase letters) are
* called COMMAND_BEFORE_START, COMMAND_AFTER_START, COMMAND_EVENT_START, COMMAND_MESSAGE.
*
* their constant values are: before_start, after_start, command_start, etc., respectively.
*
* these values: before_start, after_start, command_start, et al, cannot change during the
* lifecycle of the application. they are constant values that cannot change!
*/
// declaring class constant variables
// COMMAND_EVENT_START, COMMAND_BEFORE_START, COMMAND_AFTER_START are constant variables
// command_start, before_start, after_start are constant values
// this value 'before_start' will not change during the lifecycle of the application
const COMMAND_BEFORE_START = 'before_start';
// this value 'command_start' will not change during the lifecycle of the application
const COMMAND_EVENT_START = 'command_start';
// this value 'after_start' will not change during the lifecycle of the application
const COMMAND_AFTER_START = 'after_start';
// this value: 'An object is just a copy of the class.'
// will not change during the lifecycle of the application
const COMMAND_MESSAGE = 'An object is just a copy of the class.';
/**
* 2nd attribute of the class MyClass:
*
* the purpose of the 2nd attribute of the class is to store content values that are
* constantly changing (its values) during the lifecycle of the application.
*
* as you can see below, the property variables (declared with visibility control) are:
* $make, $model, $color.
*
* these property variables can and do change during the lifecycle of the application,
* even though, they are initialized with the initial values in the same fashion as the
* 1st attribute constants (which are initialized with the initial constant values).
*
* the difference is that the 1st attribute variable values cannot change while the 2nd can.
*
* you'll see in the example code shown later that these 2nd attribute variables
* get assigned new values every time a constructor is called.
*
* so all 2nd attribute property variables often get their values change frequently during
* the lifecycle of the application.
*
* these 2nd attribute property variables must be declared prefacing with visibility control:
*
* public, protected, private
*
* public, protected, private are called visibility control or access control.
*/
public $make = 'Toyota'; // this value 'Toyota' will change during the lifecycle of the application
protected $model = 'Tundra'; // this value 'Tundra' will change during the lifecycle of the application
private $color = 'grey'; // this value 'grey' will change during the lifecycle of the application
/**
* 3rd attribute of the class MyClass:
*
* the purpose of the 3rd attribute of the class is to calculate and manipulate
* the content values that contain in the 1st and 2nd attribute property variables.
*
* you'll see in the example code shown later that the 3rd attribute's purpose is to
* calculate and manipulate the values contain in the 1st or 2nd attribute variables.
*
* likewise, these 3rd attribute methods and functions must be declared prefacing with
* visibility control: public, protected, private
*
* public, protected, private are called visibility control or access control.
*
* in this example class definition, we have two (3rd) attributes that manipulate or
* display messages.
* notice in the constructor, the 2nd attribute values get assigned to new values constantly.
*
* For example:
*/
// notice that you can pass in whatever make, model, or color to this constructor
public function __construct($make, $model, $color)
{
// notice that this constructor, which is also a member of the 3rd attribute type, calculates and
// manipulates the content values that contain in the 1st and 2nd attribute property variables.
// $this refers to the current object or class, which is 'MyClass'
// make refers to this class MyClass' property $make declared above
$this->make = $make;
// model refers to this class MyClass' property $model declared above
$this->model = $model;
// color refers to this class MyClass' property $color declared above
$this->color = $color;
}
public function test1()
{
// notice that this function test1(), which is also a member of the 3rd attribute type, calculates and
// manipulates the content values that contain in the 1st and 2nd attribute property variables.
// $this refers to the current object or class, which is 'MyClass'
// will output: An object is just a copy of the class.
echo $this->COMMAND_MESSAGE;
// will output whatever string got passed in via the constructor, for example: Ford
echo $this->make . ", ";
// will output whatever string got passed in via the constructor, for example: F-150
echo $this->model . ", ";
// will output whatever string got passed in via the constructor, for example: Grey
echo $this->color;
}
public function test2($str)
{
// notice that this function test2(), which is also a member of the 3rd attribute type, manipulates and
// displays the content values that contain in the 1st and 2nd attribute property variables.
// will output whatever string got passed in via $str
echo $str . "\n";
}
}
?>
And then consider the following object creation using the keyword new, which mean to create an instance of a class -- or to create a copy or a clone of a class.
$str = 'An object is just a copy of the class.';
// notice that the keyword new means to create an instance of a class -- or to create a copy or a clone of a class
// creating an instance of MyClass()
// $obj is an instance of the class MyClass. it is a copy or a clone of MyClass.
$obj = new MyClass();
$obj->test1($str);
// will output an error message saying argument $str is undefined in test1().
$obj->test1();
// will output ----> An object is just a copy of the class.
// will output -----> Ford, F-150, Grey
$obj->test2();
// will output an error message saying test2() requires at least one argument.
$obj->test2($str);
// will output -----> An object is just a copy of the class.
In the above example, we create an object using keyword new. But an object can be created using a type hint as well.
You will often see objects being created using a type hint in a lot of code, particularly in other languages like
Java, C/C++, Delphi, Python, etc. A type hint is a class that derives an object that following it -- it is a
hint about what an object of which class.
In PHP, we can have type hint as well, for example:
class Foo
{
public $bar; // $bar is a property that will hold a type hint object
public $zar; // $zar is a property that will hold a type hint object
As you can see in the constructor below, it has a 'type hint' called Bar and Zar, which create
objects called $bar and $zar, respectively.
// notice the 'type hints' which indicate that $bar and $zar are ojects of Bar and Zar, respectively
public function __construct(Bar $bar, Zar $zar)
{
// constructor body
$this->bar = $bar; // now $this->bar holds an object created by a 'type hint'
$this->zar = $zar; // now $this->zar holds an object created by a 'type hint'
}
}
Now you can do anything with the objects: $this->bar and $this->zar anywhere within this class Foo.
Here are some more examples that show 'type hint':
public function __construct(TaxManager $tax)
As you can see in the constructor, it has a 'type hint' called TaxManager, which is a class, and also,
it has an object called $tax.
So $tax is just a copy or a clone or an instance of the class TaxManager.
Suppose that class TaxManager has a property called $taxRate and a method called calculateTax(),
we can use the $tax object to refer to class TaxManager's member variables/properties and methods
like you normally would with an object created using 'new' keyword. for example:
public function __construct(TaxManager $tax)
{
$this->taxrate = $tax->taxRate; // here, we're using an object $tax to refer to $taxRate
$this->tax = $tax->calculateTax(); // here, we're using an object $tax to refer to calculateTax()
}
In the above example constructor code, be careful when passing arguments. You have to
pass it like this: Invoice(new TaxManager()), assuming Invoice is the class containing the constructor above.
// Here is an example as an array object:
class NeuralNetwork
{
private $input = array(); // input information
private $hidden_layer = array(); // layers in the network
public function __construct(array $input) // notice the 'type hint' which indicates $input is an array variable
{
// constructor body
}
}
In the case of array object, array(), it tells us that $input is of type array.
In Java, you'll often see a lot of objects created using type hints, for example:
As you can see in the following, HttpServletRequest is the class and request is the object
Likewise, HttpServletResponse is the class and response is the object
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
doPost(request, response);
}
try
{
// As you can see MimeMessage is the class and message is the object
MimeMessage message = new MimeMessage(session);
}
catch (MessagingException mex) // Likewise, MessagingException is the class and mex is the object
{
mex.printStackTrace();
}
A class
is the program you write (i.e., the MyClass
class implementation above); while object
(i.e., $obj) is the copy of the class or the clone of the class, most often being known as the instance
of the class (MyClass
, in this case).
A class
resides in ROM
(a permanent memory area: Read Only Memory
), whereas object
(i.e., $obj) resides in RAM
(a temporary memory area: Random Access Memory
.)
In ROM
, data is stored there permanently even when the computer is turned off. In a RAM
memory area, on the other hand, data get stored temporarily while the program is running or while the computer is still turned on. When the computer is turned off, the RAM
data (i.e., $obj) is completely erased and is no longer stored in the RAM
.
Instances
of a class can be useful only while the program is running or while the computer is turned on; and when the program is not running or when the computer is turned off, instances
of a class are no longer useful to a program; and therefore, it is stored in a temporary memory area.
Instances
of a class can be created 'on the fly
' at any time when needed by a program [as you can see above: $obj = new MyClass()].
Instances
of a class are often being created from everywhere when needed (i.e., libraries, frameworks, and other classes, etc.)
So there is no need to store instances
of a class permanently in permanent memory spaces and wasting valuable memory spaces.
to create an object, use the keyword new in the front of a class
objects can be created using 'type hint' as well
the keyword new means to create an instance of a class -- or to create a copy or a clone of a class
an 'object' is just a copy or a clone or an instance of a class!
a class has three types of attributes!
1st attribute of the class:
the purpose of the 1st attribute of the class is to store content value that is
constant and can't change its value during the lifecycle of the application
2nd attribute of the class:
the purpose of the 2nd attribute of the class is to store content value that is
constantly changing its value during the lifecycle of the application.
3rd attribute of the class:
the purpose of the 3rd attribute of the class is to calculate and manipulate the
content values that contain in the 1st and 2nd attribute property variables.
Note:
In programming, a class mimmicking a real world object, in which, it has attributes
just like a real world object has. For example, say, a real world human has two arms,
two legs, a name, address, email, phone, username, password, a face, hair, and other
body parts.
All those are called attributes -- attributes are some entities that enable the "body"
or "object" (or a human in this case) to function properly. "Attribute" means to "help."
All those attributes are called properties in programming and also usually known as
variables. Variables are just a term used to hold values in programming (or in computer memory).
They are placeholders to hold values in the computer memory so that they can be stored
and retrieved.
So when people say attributes, properties, and variables, they mean those three having the
same meaning and they are being used interchangibly.
For example, I use: 1st and 2nd 'attribute' 'property' 'variable' in my description throughout
this tutorial -- all in one phrase: 'attribute property variable' to emphasize the meaning of
the placeholder in computer memory, which is an attribute or a property or a variable.
All three have the same meaning and can be used interchangibly -- most often being used as one
phrase (as you'd seen throughout my description).
I found that beginning programmers are often confused with the word 'property' when they see one.
Just know that in programming, we often use the word property a lot to mean variable.
And also in programming, we often use the word attribute a lot to mean variable or function
(also known as method).
The three have the same meaning and can be used interchangibly -- and often as one phrase.
As you can see, a class has three attributes: 1st is the constants, 2nd is the variables, 3rd is
the functions (also known as methods).
In the dictionary the word 'attribute' means a quality or feature or property
regarded as a characteristic or inherent part of someone or something. Verb: to help!
In computer programming the word 'attribute' means a piece of information which
determines the properties of a field or tag in a database or a string of
characters in a display.
A true definition of a class is an object
-oriented model mimicking how real objects behave. For example, a class called Car would have the usual three attributes: the engine (implemented as const COMBUSTIBLE_ENGINE = 'v8-engine'; (2nd attribute implemented as properties) the make, model, color; and (3rd attribute) at a minimum it must contains the constructor function to initialize the objects and the ignition (implemented as a method called Ignition()) to start the car.
That is object-oriented class. So when you think of a class, think of it as a real world object that exists in the real world. That's what a class is -- a real world object that you can observe.
An object-oriented class is a class that mimicks or behaves like a real world object.
You may have heard people mentioned the term object-oriented programming when talking about building applications or when talking about programming methodologies in general.
They are really talking about classes. Classes are object-oriented methodology.
In the old days (the 1960s, 1970s and up to the first half of the decade of 1980s), there were no object-oriented programming methodologies available. There were no classes available. So programmers had to program the hard way using only variables, methods, functions, and procedures to do their programming work.
That was during the early days of the technology revolution and the Web hadn't even been invented yet. So you couldn't program anything sophisticated up to the first half of the decade of the 1980s because object-oriented programming hadn't been invented yet (or more specifically, classes or the concept of classes hadn't been invented yet).
During the second half of the decade of the 1980s and onward, object-oriented programming was developed and enabled very sophisticated applications to be developed to this day. Classes were the foundation of the technological revolution. Without classes we wouldn't have been able to program very sophisticated applications.
Today, if you hear people talk about object-oriented programming, just ask them: What is a non-object-oriented programming? (To see if they know one exists.)
There are none!!!
All of today's programming are object-oriented programming. So the term object-oriented programming is obsolete and it has been obsolete since the start of the millenial decade (2000s). It is irrelevant nowaday and onward.
So keep this in mind: All classes are object-oriented programming methodology. Classes mimick how real world objects behave. Classes are the foundation of the programming world.
When you approach to building (or creating a class), you first think of the real world object that class represents (i.e., a car, a person, a customer, an employee, a student, etc.) and then you proceed to creating that class by using the three attributes to represent the real world object that forms the class that you're creating.
For example, if you want to program an application about a person, whether that person is a student, a teacher, a co-worker, a doctor, a lawyer, a customer, or an employee of a company, etc, you would think in term of real world about that person, which is, that person has a name, an address, a phone, email, a username, a password, etc.
By the way, a person is a very generic term and it can be applied to other uses as well; for example, it can be applied to a customer, a student, a teacher, a co-worker, a doctor, a lawyer, a customer, or an employee of a company, etc.
Question: How would you create a class for that person? Or for any person? Or for a generic uses of/for that person?
The answer to that question can be varied depending on what type of application you're building, but all cases require you to think of the real world object implementing the three attributes that form the foundation of the class.
For example, if you're building an application to store a person's personal profile, you would start with a person and list the attributes of that person. For example, a person has a name, address, phone, email, username, password, etc.
Next, ask yourself a question: which of the items belong to the 1st attribute of the class? Which belong to the 2nd attribute of the class? Which belong to the 3rd attribute of the class? And finally, which belong to none of the above?
Well, by looking at the list, we can see clearly that 'address' stands out among them, because 'address' has attributes of its own: street number, apt #, suite #, city, state, zip, country, etc.
This means that 'address' is just like 'person' and they both have attributes of their own. So both 'person' and 'address' are classes. None of the rest in the list have attributes, so they are either belonging to the 1st or 2nd attribute of the class.
Knowing that, we can go ahead and create two classes called Address and Person to record that person's profile information.
Now since class Person has an attribute called address and address has attributes of its own, we can say that address is a supporting class of Person. In other words, class Person needs class Address to make class Person more suiteable to record a person's profile because in the real world a person needs an address to live in.
Now let's build those classes: Address and Person:
<?php
/**
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
* notice that the namespace points to the folder names called 'path', 'to', 'model'
* you can rename them accordingly!
* 'path', 'to', and 'model' are actually folder names containing the models or classes
* if you desire to have more levels of folders, you can add them accordingly,
* for example: namespace path\to\my\resource\model;
* of course, you need to autoload them accordingly as well, or else
* it won't work!
* see my other tutorial called 'How to autoload classes using SPL'
* or you can use class level loading and remove the namespace and the use clauses
* and it will work just fine!
* just put the include statement(s) at the top of every class that uses the file!
*
* as you can see in the namespace, you can put all of your model in a folder called 'model',
* including this class Address
*/
// 'path', 'to', and 'model' are actually folder names containing the models or classes
namespace path\to\model;
class Address
{
// 1st attribute of the class Address:
// the purpose of the 1st attribute of the class is to store constant value.
// declaring class constant variables
// for class Address there are no constant variables
// you may find a use of the constant for Address, however!
// 2nd attribute of the class Address:
// the purpose of the 2nd attribute of the class is to store property
// variable values that are constantly changing during the lifecycle
// of the application.
// the 2nd property variables must be declared prefacing with visibility control.
// public, protected, private are visibility control.
// notice that class Address has an attribute called name
// well, if you think in the real world term, an address is for somebody to live
// in or an address is an object that can accomodate other objects: a person or a name
// in this case, an address has a name of a person tied to it as its attribute
// in programming an application, we need to associate a name of a person to
// the object called Address so that we can relate them to one another
public $name;
public $street1;
public $street2;
public $city;
public $state;
public $zip;
public $country;
// 3rd attribute of the class (Address):
// the purpose of the 3rd attribute of the class is to calculate
// and manipulate the values of the 1st and 2nd attributes of the class.
// 3rd attribute methods must be declared prefacing with visibility control
// public, protected, private are visibility control.
// for the 3rd attribute in the example below, most of the tasks are being done
// to validate the address's 2nd attributes so that they all are
// valid attributes.
// that is all that need to be done for the class Address
// very simple and can be utilized by others like: customer, student, employee, etc.
public function isNameValid()
{
// this function will return the full name of the person
// if you desire to seperate the first/last name of the person
// you can do so accordingly very easily!
return strlen($this->name) > 0;
}
public function isStreet1Valid()
{
// this function will return the street address1 of the person
// notice that there is no need to validate street address2
// because street address2 is optional and generally for apt, suite, etc.
return strlen($this->street1) > 0;
}
public function isCityValid()
{
// this function will return the city address of the person
return strlen($this->city) > 0;
}
public function isStateValid()
{
// this function will return the state of resident of the person
return strlen($this->state) == 2;
}
public function isZipValid()
{
return strlen($this->zip) == 5;
}
public function isCountryValid()
{
return strlen($this->country) > 0;
}
// this function is being called by class Person's validate() method and it looks like this:
// return $this->billingAddress->validate();
// with billingAddress being an instance of class Address
// and it is very very elegance!!!
// to see an even more elegance(ness) at work, please see class Main later!
public function validate()
{
// this function will return the valid name of the person
return $this->isNameValid();
}
}
?>
Remember that, an address is a supporting class of Person. In other words, class Person needs class Address to make class Person more suiteable to record a person's profile.
Okay, let's create a person class to record that person's profile information. For example:
<?php
/**
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
* notice that the namespace points to the folder names called 'path', 'to', 'model'
* you can rename them accordingly!
* 'path', 'to', and 'model' are actually folder names containing the models or classes
* if you desire to have more levels of folders, you can add them accordingly,
* for example: namespace path\to\my\resource\model;
* of course, you need to autoload them accordingly as well, or else
* it won't work!
* see my other tutorial called 'How to autoload classes using SPL'
* or you can use class level loading and remove the namespace and the use clauses
* and it will work just fine!
* just put the include statement(s) at the top of every class that uses the file!
*
* notice that the use clause references the folders: 'path', 'to', 'model' as well as
* the class name called 'Address'
* this is needed!
* now class Person has access to class Address in full capability as if you had
* used the class level loading method!
* either method will work just fine, but namespace and application level loading is
* more robust and efficient!
*
* as you can see in the namespace, you can put all of your model in a folder called 'model',
* including this class Person and the previous class Address
*/
// 'path', 'to', and 'model' are actually folder names containing the models or classes
namespace path\to\model;
use path\to\model\Address;
/**
* this class is very generic and it can be changed to other uses as well,
* for example, you can rename it to Customer, Student, Employee, etc.
*/
class Person
{
/**
* 1st attribute of the class (Person):
* declaring class constant variables
* for class Person there are no constant variables
* you may find a use of the constant for Person, however!
*
* 2nd attribute of the class (Person):
* class properties: properties must be declared prefacing with visibility control
* public, protected, private are visibility control:
*
* if you remember the list, a person has an address and that address has already
* been taken care of earlier in a class called Address
*
* now we need to glance over the list again and we can see that it has email, phone,
* social security, username, password, etc.
*
* so we need to implement those as the 2nd attributes
*
* in case you're doing an ecommerce shopping site, you can use this
* property variable called $billingAddress to direct your application to
* the billing address during the check out process
*
* yes, these classes/applications/codes are very generic and you can customize
*them to suit your objectives!
*/
public $billingAddress;
public $email;
public $phone;
public $social_security_number;
/**
* 3rd attribute of the class (Person):
* class methods: methods must be declared prefacing with visibility control
* public, protected, private are visibility control:
*
* for the third attributes, we start with a constructor to initialize the class
* Address
* more specifically, we need to create an instance of the class Address and
* store it in the 2nd attribute variable called billingAddress
* the rest of the 3rd attributes are just methods to validate the 2nd attributes
* if you have other ideas for other 3rd attributes to accomplish something, like
* looking up in a database to retrieve something, you can add them here in
* the 3rd attribute section
*/
public function __construct()
{
// this constructor function will assign an instance of the address of the
// person to the 2nd attribute property variable called 'billingAddress'
// this way, you can access the person's address info from other
// classes that make use of this person address info!
$this->billingAddress = new Address();
}
public function getName()
{
// this function will return the valid full name of the person
return $this->billingAddress->name;
}
public function validateSocialSecurityNumber($social_security_number)
{
// this function will return the valid social security number of the person
// you might want to do a better job in validating social security number than this
return preg_match('/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/', $social_security_number);
}
public function isSocialSecurityNumberValid($social_security_number)
{
// this function will return the valid social security number of the person
return $this->validateSocialSecurityNumber($social_security_number);
}
public function validateEmail($emailToValidate)
{
// this function will return the valid email of the person
// check if email address is well-formed using PHP's built-in filter_var()
// Google the Web for a more robust email validation function
return filter_var($emailToValidate, FILTER_VALIDATE_EMAIL);
}
public function isEmailValid()
{
// this function will return the valid email address of the person
return $this->validateEmail($this->email);
}
public function validatePhone($phone)
{
// this function will return the valid phone of the person
return preg_match('/^[0-9]{3}$/', $phone);
}
public function isPhoneValid()
{
return $this->validatePhone($this->$phone);
}
public function validate()
{
// this function will return the valid billing address of the person
// notice that this call is to the class Address's validate()
return $this->billingAddress->validate();
}
}
?>
Now we got two classes supporting each other: Person and Address.
So let's build a service application that makes use of the two classes to store a person's personal profile. For example:
<?php
/**
* notice that the namespace points to the folder names called 'path', 'to', 'model'
* 'path', 'to', and 'model' are actually folder names containing the models or classes
* you can rename them accordingly! this class assumes to reside in 'path/to/model' folder!
* if you desire to have more levels of folders, you can add them accordingly,
* for example: namespace path\to\my\resource\model;
* of course, you need to autoload them accordingly as well, or else
* it won't work!
* see my other tutorial called 'How to autoload classes using SPL'
* or you can use class level loading and remove the namespace and the use clause
* and it will work just fine!
* just put the include statement(s) at the top of every class that uses the file!
*
* as you can see in the namespace, you can put all of your model in a folder called 'model',
* including this class Application and the previous classes: Address, Person, and any other
* model classes that you might have
*/
// 'path', 'to', and 'model' are actually folder names containing the models or classes
namespace path\to\model;
/**
* notice that the use clause references the folders: 'path', 'to', 'model'
* as well as the class names called 'Address' and 'Person'
* this is needed!
* now class Person has access to class Address in full capability as if you had
* used the class level loading method!
* either method will work just fine, but namespace and application level loading is
* more robust and efficient!
*/
use path\to\model\Address;
use path\to\model\Person;
/**
* this class will make use of the other classes: Address, Person
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
*/
class Application
{
// 1st attribute of the class (Application):
// declaring class constant variables
// for class Application there are no constant variables
// you may find a use of the constant for Application, however!
// 2nd attribute of the class (Application):
class properties: properties must be declared prefacing with visibility control
public, protected, private are visibility control:
public $person;
public $workAddress;
public $foreignAddress;
// in case you order items online and bill it to a different address, i.e., your employer
// yes, I've seen strange things people do!
public $billingAddress;
// in case you order items online and has a different address to ship, i.e., your landloard
// yes, I've seen strange things people do with their shipment!
public $shippingAddress;
// of course, you can have lots more 2nd attributes here!
// 3rd attribute of the class (Application):
class methods: methods must be declared prefacing with visibility control
public, protected, private are visibility control:
public function __construct()
{
// this constructor function will assign an instance of the address of the person to the
// 2nd attribute property variable called 'shippingAddress' (among other assignments)
// this way, you can access the person's address info from other
// classes that make use of this person address info!
// also this is in case you need to have your packages ship to a different location!
$this->billingAddress = new Address();
$this->shippingAddress = new Address();
$this->workAddress = new Address();
$this->foreignAddress = new Address();
$this->person = new Person();
}
public function validate()
{
// this function will return true or false depending on whether a person
// info has been validated or not!
// notice the call to $this->person->validate() is actually calling
// class Person's method called validate()
//
// just follow this elegant code flow and you'll be fine!
return $this->person->validate();
}
// of course, you can have more functions to do other things as well!
}
?>
At this point, all of the models have been created and from here and on, you can create external controller classes to make use of the models: Address, Person, and Application.
Remember that, controller (specifically external controller) dictate or delegate, organize the tasks. It is akin to office managers dictating and delegating the tasks to their employees. Employees do all the work and managers do very little work and only organize, dictate, and delegate the tasks.
Now what's left is to create an instance of the class Application and use it accordingly. For example:
<?php
/**
* this class is a controller class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
*
* if you remember that a controller class in an MVC scheme of thing does very
* little work. however, in this class, I broke that rule by doing a lot work in
* here like grabbing all the POST variables and store them in the 2nd attributes
* of the model classes
*
* well, sometimes I break my own rule because of my laziness instead of doing all of the
* handling of the POST tasks in the actual "external" controller and not in the base controller!
*
* just to be clear: nothing stops you from doing what I'm doing here!
* however, the downsize is that you are setting up yourself to repeat this habbit
* over and over and over again and that's will make you a bad programmer!
* and one of these days your code will contain bugs!!!
*
* to be proper, this class should do very little of coding, and that is, it should
* just create an instance of the model and ask the model if the POST variables that
* are sent by the user are valid: true or false!
*
* or in most cases, in the model, there should be method(s) that handle the POST
* items accordingly and insert them into the database!
*
* that method that handles/inserts POST items into the database should return true when
* the items are inserted into the database successfully, and false otherwise!
*
* again here, due to my laziness, I bypassed all that tasks completely and only to
* implement this as a base controller class to give you somewhat a guideline for you
* to complete the tasks (yourself) of building a functional application.
*
* actually, this class is a "main" controller base class in an MVC scheme of thing,
* similar to classes Base in "Advanced Programming: MVC" and class Example in my other
* tutorial called 'How to autoload classes using SPL'
*
* so in actuality, I did not provide "external" controller classes for this example and
* only leave them for you to implement your own as well as your own view, too!
* this ends the topic about MVC rant!
*
*
* notice that the namespace points to the folder names called 'path', 'to', 'controller'
* you can rename them accordingly! this class assumes to reside in 'path/to/controller' folders!
* if you desire to have more levels of folders, you can add them accordingly,
* for example: namespace path\to\my\resource\controller;
*
* of course, you need to autoload them accordingly as well, or else
* it won't work!
* see my other tutorial called 'How to autoload classes using SPL'
* or you can use class level loading and remove the namespace and the use clause
* and it will work just fine!
* just put the include statement(s) at the top of every class that uses the file!
*
* as you can see below, you can put all of your controller in a folder called 'controller'
*/
namespace path\to\controller;
/**
* notice that the use clause references the folders: 'path', 'to', 'model'
* as well as the class name called 'Application'
* this is needed!
* now class Main has access to class Application in full capability as if you had
* used the class level loading method!
* either method will work just fine, but namespace and application level loading is
* more robust and efficient!
*/
use path\to\model\Application;
/**
* this class will make use of the class Application
*/
class Main
{
// 1st attribute of the class (Main):
// declaring class constant variables
// for class Main there are no constant variables
// you may find a use of the constant for Main, however!
// 2nd attribute of the class (Main):
class properties: properties must be declared prefacing with visibility control
public, protected, private are visibility control:
public $app;
// of course, you can have lots more 2nd attributes here!
// 3rd attribute of the class (Main):
class methods: methods must be declared prefacing with visibility control
public, protected, private are visibility control:
public function __construct()
{
// this constructor function will assign an instance of the address of the
// person to the 2nd attribute property variable called 'shippingAddress'
// this way, you can access the person's address info from other
// classes that make use of this person address info!
// also for in case you need to have your packages ship to a different location!
$this->app = new Application();
// all of these are just assigning the POST items sent by the form and put them
// into their proper variables! nothing special!
// this happens whenever a user fills out a form and press 'submit' button and
// they all will come here and you can grab those items and use them here and
// anywhere else for that matter!
// you can insert these POST items into the database as well!
// notice that, you can set this property called 'app' so that the view can
// use them. see "Advanced Pattern Programming: MVC" where I show a set()
// and a get() for the purpose of setting all these properties in class Base()
// so assuming if you have an "external" controller to handle these POST,
// you would do like this in that "external" controller:
// $app = new Application();
// $base = new Main(); // or Base() in the MVC example!
// $base->set('app', $app->person->billingddress);
// remember that in PHP, you can use properties on the "fly" without
// having to declare them first!
// in here, we set the undeclared property called 'app' and class Base will happily
// accepts 'app' as its own property! awesome!
// now in the view, you can retrieve that property by doing this:
// $main = new Main();
// $app = $main->get('app');
// you can display these values to your users or do whatever with them!
// foreach ($app as $value)
// {
// $name = $value->name; // $name = 'John Doe'
// $street1 = $value->street1; // $street1 = '123 Main St'
// $city = $value->city; // $city = 'Minneapolis'
// }
$this->app->person->billingddress->name = $_POST ['name'];
$this->app->person->billingddress->street1 = $_POST ['street1'];
$this->app->person->billingddress->street2 = $_POST ['street2'];
$this->app->person->billingddress->city = $_POST ['city'];
$this->app->person->billingddress->state = $_POST ['state'];
$this->app->person->billingddress->zip = $_POST ['zip'];
$this->app->person->billingddress->country = $_POST ['country'];
$this->app->person->billingddress->email = $_POST ['email'];
$this->app->person->billingddress->phone = $_POST ['phone'];
// you can do the same thing for other addresses, i.e., shippingAddress
// of course, you have to grab from the proper form values sent by your users
// here, we assume that the shipping and billing address are the same!
$this->app->person->shippingAddress->name = $_POST ['name'];
$this->app->person->shippingAddress->street1 = $_POST ['street1'];
$this->app->person->shippingAddress->street2 = $_POST ['street2'];
$this->app->person->shippingAddress->city = $_POST ['city'];
$this->app->person->shippingAddress->state = $_POST ['state'];
$this->app->person->shippingAddress->zip = $_POST ['zip'];
$this->app->person->shippingAddress->country = $_POST ['country'];
$this->app->person->shippingAddress->email = $_POST ['email'];
$this->app->person->shippingAddress->phone = $_POST ['phone'];
}
// of course, you have some functions to do other things as well!
}
?>
Okay, you've seen how you approach in building an application large or small by laying out a road map by thinking that a class mimicks a real world object and using the guideline shown in this tutorial should help you build any application large or small in an elegance way.
There you have it!
And have fun building applications!
A very simple and short answer is: A constructor is just an empty or blank function.
That is it! A hollowed empty function that contains nothing! That's what a constructor is. It's an empty or blank function that contains nothing.
A constructor __construct() is often known as a magic method because PHP does its magic behind the scene by calling it or invoking it magically behind the scene whenever you create an instance of its class.
There are many magic methods in PHP and the following method names are considered magical: __get(), __set(), __isset(), __unset(), __construct(), __destruct(), __call(), __callStatic(), __sleep(), __wakeup(), __serialize(), __unserialize(), __toString(), __invoke(), __set_state(), __clone(), and __debugInfo().
Notice that they all use the __ (double underscores), including __construct().
Notice also that all these magic methods are magically called by PHP automatically. For more, please see my other tutorial called Magic Methods: __set(), __get(), __isset(), __unset()
Earlier, we talked about the definition of a class. Now we're talking about the definition of a constructor, which is just an empty function.
That empty(ness) is by design to allow programmers to put some code in it.
Remember that a class has three attributes: 1st, 2nd, and 3rd attributes.
The 3rd attribute contains one of the most important attribute of the class concept, and that attribute is called a constructor.
What is so significant about a constructor?
A constructor is very significant, in that, it gets called every time its class gets referenced.
I repeat: A constructor gets called every time its class gets referenced.
The keyword is referenced -- meaning, called or instantiated. For example, $obj = new MyClass().
As you can see, MyClass gets referenced and if it has a constructor, its constructor will get called or executed automatically.
This is very significant because it gets called automatically without you having to explicitly call it as you normally would with other 3rd attributes.
So you can say that a constructor is an empty special 3rd attribute of the class. No one else in the 3rd attribute category that has any special preferential treatment like a constructor does.
With this priviledge (and empty-ness), you can put all kinds of code in the constructor to be executed automatically whenever its class is referenced. Very neat!!!
Typically, the kinds of code you put in the constructor are code that needed to be instantiated or initialized. You've seen in class Person, its constructor contains a line of code that instantiating an address class: $this->address = new Address().
You don't do a lot of heavy duty programming like querying a database inside a constructor. You leave all of the heavy duty jobs to other 3rd attributes. The purpose of a constructor is just to do simple and quick instantiations and initializations of the code. Nothing else!
Note: The variable $this refers to the current class (or object) which is class Person (in the case of $this->address = new Address()).
A class does not require a constructor if the class doesn't need to instantiate or initialize other objects or code. In other words, if you don't need your code to be executed automatically every time your class is referenced, then you don't need a constructor for your class.
When creating a class, you have to decide whether your class needs a constructor or not depending on whether your class needs to instantiate or initialize any objects (or code) at all.
Another point of note is that, you have to decide whether or not some of the code inside your class need to get executed automatically whenever your class gets referenced. Anything inside a constructor will get executed automatically whenever its class is referenced.
In summary, the purpose of the constructor is to get code executed automatically every time its class gets referenced. That's all a constructor does and nothing else. If you don't have code that needs to be executed automatically every time your class gets referenced, then you don't need a constructor for your class.
In the following example, function Connect() gets executed automatically whenever class Connection gets referenced, even though function Connect() is outside of the constructor, because a code inside the constructor calls it.
This is how you make your non-constructor functions get called automatically whenever their class gets referenced. For example:
<?php
/**
* as you can see in the namespace, you can put all of your model in a folder called 'model'
*/
namespace path\to\model;
class Connection
{
// 2nd attribute of the class (Connection):
private $username;
private $password;
private $db_name;
private $host;
private $isConnect;
// 3rd attribute of the class (Connection):
public function __construct($user, $pass, $dbName, $url)
{
// initialize the variables username, password, host, db_name, with the
// argument values sent in via the contructor heading: user, pass, dbName, url
// notice that variable $this refers to the current object: $obj = new MyClass()
$this->username = $user;
$this->password = $pass;
$this->db_name = $dbName;
$this->host = $url;
$this->isConnect = $this->Connect();
}
public function Connect()
{
// notice that this function gets called automatically whenever class Connection
// gets referenced because this function gets included in the constructor above!
// this function returns the PDO connection object
return new PDO("mysql:host=$this->host;dbname=$this->db_name", $this->$username, $this->$password);
}
} // end class Connection
/**
* Usage:
*
* $pdo = new Connection('my_username_123', 'my_password_123', 'my_database_name_123', 'my_db_server_123');
*
* The above creation of an instance of class Connection causes the class Connection to get
* referenced, and as a result of this referenced, its constructor gets called automatically!
* Now you can use the instance of class Connection as you normally would:
*
* if ($pdo) // we could do this as well: if ($pdo->Connect)
* {
* // it is connected
* $sql = 'SELECT * FROM myTable';
* $query = $pdo->prepare($sql);
* $resource = $query->execute();
* $result = $resource->fetch(PDO::FETCH_ASSOC);
*
* // now you can do whatever with the associative array variable $result
*
* while ($row = $result->fetch())
* {
* // well, I'm just pretending that 'myTable' contains only a username and password
*
* $username = $row['username'];
* $password = $row['password'];
* }
*
* }
*/
?>
As stated earlier, a constructor is automatically called whenever its class gets referenced. This means that we do not need to call a constructor directly and manually by hand -- it is automatically called by the programming compiler behind the scene whenever its class gets referenced. The keyword here is referenced.
To refer (or reference) a class, you create an instance of a class. For example:
<?php
/**
* as you can see in the following, we refer to classes Address and Person by creating instances of the
* classes using keyword new
*
* now since class Address doesn't have a constructor, the reference didn't trigger a call to the constructor
*
* on the other hand, a reference to classes Person and Connection will trigger a call to its respective
* constructor because both classes Person and Connection have their own constructor
*/
$this->foreignAddress = new Address();
$this->person = new Person();
$pdo = new Connection('my_username_123', 'my_password_123', 'my_database_name_123', 'my_db_server_123');
?>
Since the purpose of a constructor is to allow you to put some code in it to be executed automatically by the compiler, you can pass outside values as parameters of the class to its constructor to be executed automatically, and thus allow you to use those outside values to initialize variables/properties of the class inside a constructor.
As you can see from the previous example in class Connection, it passes outside values to the constructor to be used as connection parameters. For example, class Connection has four parameters to be passed in via its constructor:
<?php
public function __construct($user, $pass, $dbName, $url)
?>
And then we can pass outside values to class Connection via its constructor like the following.
Notice that you pass outside values to the class through its constructor. This means that the outside values you pass to the class must match the number of parameters contain in the constructor.
In this case, we pass four outside values: 'my_username_123', 'my_password_123', 'my_database_name_123', 'my_db_server_123' to correspond with the constructor parameters $user, $pass, $dbName, $url, respectively.
<?php
$pdo = new Connection('my_username_123', 'my_password_123', 'my_database_name_123', 'my_db_server_123');
?>
Now class Connection has full control of the outside values at its disposable. It can do whatever it wants with these outside values inside class Connection.
That is how you pass outside values to a class to be calculated and manipulated in a class.
Remember that the purpose of the 3rd attribute (including the constructor) of a class is to calculate and manipulate values of the 1st and 2nd attributes of the class?
These outside values get assigned to the 2nd attribute of a class inside the constructor. The constructor is also a member of the 3rd attribute of a class.
Earlier I mentioned that if you have some code that need to be executed automatically whenever its class gets referenced, you need to put them in the constructor. However, the constructor is not the only "game in town" that you can put your code to be executed automatically whenever its class gets referenced -- there is another "game in town" that can accomplish this very same thing. You can use a neat trick to accomplish the same thing a constructor does. Here is how.
<?php
/**
* Illustrating a neat trick to mimick a constructor
*/
namespace path\to\model;
class MyClass
{
// 2nd attribute of the class (MyClass):
public $make;
public $model;
public $color;
// 3rd attribute of the class (MyClass):
public function __construct($make = null, $model = null, $color = null)
{
// initialize variables $make, $model, $color
// notice that variable $this refers to the current object: $obj = new MyClass()
$this->make = $make;
$this->model = $model;
$this->color = $color;
}
public function init()
{
// notice that this function gets called automatically whenever class MyClass
// gets referenced because this function gets included at the bottom of this class!
// see the call to this function at the bottom of this class
// you can do whatever you desire inside this init(), such as code initializations
// $address = new Address();
// but here, we'll just return null for this illustration!
return null;
}
} // end class MyClass
// Notice that this call is outside of class MyClass but inside the file MyClass.php
// In fact, in here, you can call as many functions/methods as you want to mimick a constructor.
$obj = new MyClass();
$obj->init();
/** THIS IS THE END OF FILE: MyClass.php **/
/**
* Usage:
*
* $obj = new MyClass('Toyota', 'Camry', 'blue');
*
* The above creation of an instance of class MyClass causes the class MyClass to get
* referenced, and as a result of this referenced, its method init() also gets called automatically!
* Now you can use the instance of class MyClass as you normally would.
*
* Notice that every time this class (MyClass) gets referenced, it runs all the way down to
* the bottom of the file, and in effect, it executes the line that calls init()
*
* As you can see, this is a very neat trick to mimick a constructor in case your
* constructor is to bulky or congested to put more code in it.
*
* Using this trick will make your constructor very lean, especially if you have lots and lots
* of code to initialize.
*/
?>
Now that you know a lot about classes and its constructors, let's see some example uses so that you can build upon the knowledge you'd learned thus far.
Remember that classes Address and Person are very generic which means that you can customize them and use them for other purpose as well.
Suppose that you're building an ecommerce application, the first question you ask yourself is: What is an ecommerce?
Well, everybody knows that an ecommerce is a place or platform that allows people to buy and sell things.
Okay, the next question you ask yourself is: What sort of things involved in an ecommerce transaction; in other words, what do you need in a shop or online shop if you're going to allow shoppers to be able to shop at a store or at an online shopping site? What do you need?
To answer that question, you follow the same process shown earlier with the classes Address and Person and think of the real world scenario and apply it to your starting point.
This means that an ecommerce involves a person, also known as a customer. So immediately we can say that we need a 'Customer' class but we already have a generic class called 'Person' that we can use to customize it to suite our purpose. So just change the already created 'Person' class into a 'Customer' class and we're all set to go.
Next, a customer has an address, email, phone, username, password, etc. Again, we already have a generic class called 'Address' and so we're all set to go.
Next, a customer (or an ecommerce) has to have a cart for customers to use. In other words, a 'Customer' class will interact with a 'Cart' class.
So the next question is: What is a cart?
Well, a cart is for putting items in it.
Now clearly from the description above a cart has an attribute called 'item'.
The next question is: What is an item?
Well, an item has a name, description, the shape and size, color, a picture (a url), etc., to identify itself.
So clearly we know that a cart has attributes (just item for now) and an item also has attributes. So we will need to create a class called 'Cart' and as well as a class called 'Item'. [Remember that we already have a generic class called 'Person' that we can use to customize it into a 'Customer' class.]
The next question is: Are there anymore attributes for a cart or for an item?
Yes, there are for both. For the cart, a shopper can add and remove items to and from the cart. So clearly right now we know that a cart has at least three attributes: Item, addItem(), removeItem().
There maybe more, such as to calculate the total price, to count the items, to apply discount and promo, to calculate the weight, etc.
For now, we follow the same process outlined earlier with the classes: Address and Person.
For example, class Cart has these attributes: Item, addItem(), removeItem().
By looking at the list, we can see clearly that Item stands out among the three attributes. Item has its own attributes: id, price, description, color, size, shape, make, model, url, image, etc.
This means that Cart and Item are classes, with Item acts as a supporting class of class Cart.
Now let's create these classes called 'Item' and 'Cart'. For example:
<?php
/**
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
* as you can see in the namespace, you can put all of your model in a folder called 'model'
*/
namespace path\to\model;
class Item
{
/**
* 2nd attribute of the class (Item):
*
* remember that the purpose of the 2nd attribute of the class is to store
* property values that are constantly changing during the lifecycle of the application.
*
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
* as you can see in the namespace, you can put all of your model in a folder called 'model'
*
* again, using real world scenario, what sort of attributes an item has?
*
* clearly, an item has an id to identify itself whether it is an apple or an orange!
* it has a quantiy to tell how many a customer buys!
* next, price for each item!
*
* you can add some more attributes like product name, description, url, image, etc.
*
* the other two: discount and product are just extra things that you can add on
* to make your item relate to the customer in a shopping cart!
*/
public $id;
public $qty = 0;
public $price;
public $discount = 0;
// we could just as well name this attribute as 'catalog' which is more appropriate
// property variable $product holds products/items in the catalog
// it is an array of items in the catalog!
//
public $product = null;
/**
* 3rd attribute of the class (Item):
*
* remember that the purpose of the 3rd attribute of the class is to calculate
* and manipulate property values contain in the 1st and 2nd attributes.
*
* class Cart (below) references this class Item and in effect triggers a call to this
* constructor. for example:
*
* $this->item[$id] = new Item($qty, $product);
*
* argument $product being the catalog array of items!
*/
public function __construct($qty, $product)
{
// initialize the variables qty and product, with the
// argument values sent in via the contructor heading: $qty, $product
// notice that variable $this refers to the current object or current
// class 2nd attributes: qty, product
$this->qty = $qty;
$this->product = $prodcut;
}
public function getName()
{
// return the name of the product/item
return $this->product->name;
}
public function getPrice()
{
// return the price of the product/item
return $this->product->price;
}
public function getWeight()
{
// return the weight of the product/item
// notice that a product/item has many other attributes as well: size,
// make, model, color, etc.
// I'll leave all of that details for you to implement your own purpose!
return $this->product->weight;
}
public function getUrl()
{
// return the url of the product/item
// again, a product has to have a url to link to
return $this->product->url;
}
public function getQty()
{
// return the qty of the product/item
return $this->qty;
}
public function getProduct()
{
// return the actual product which was sent via the constructor
return $this->product;
}
public function extendedPrice()
{
// return the total price of the product/item minus discount
return ($this->qty * $this->getPrice * (1 - $this->discount);
}
public function discountedAmount()
{
// return the total discount amount of the product/item
return ($this->getPrice * $this->discount);
}
public function getDownload()
{
// this is just extra function to return a download material
// maybe not applicable or it may! remember that a product is vast!
return $this->product->download;
}
} // end class Item
/**
* Usage:
*
* $item = new Item($qty, $product);
* or $this->item[$id] = new Item($qty, $product);
*/
?>
Now that we got an Item class, we can just go ahead and build a 'Cart' class to put (or manipulate) that Item class. For example:
<?php
/**
* this class is a model class in an MVC scheme of thing
* see my other tutorial about MVC called Advanced Pattern Programming: MVC
* as you can see in the namespace, you can put all of your model in a folder called 'model'
*/
namespace path\to\model;
use path\to\model\Item;
class Cart
{
/**
* 2nd attribute of the class (Cart):
*
* remember that the purpose of the 2nd attribute of the class is to store
* property values that are constantly changing during the lifecycle of the application.
*
* remember that a shopping cart's purpose is to hold items and thoses items get
* added and removed constantly.
*
* so clearly we need an array to hold those items and this array variable will get
* used and manipulated constantly during the lifecycle of the application.
*/
public $item = array();
/**
* 3rd attribute of the class (Cart):
*
* remember that the purpose of the 3rd attribute of the class is to calculate
* and manipulate property values contain in the 1st and 2nd attributes.
*
* the bulk of building an application usually takes place in the 3rd attribute section of
* the class, and here, there are no exceptions -- we do all of the cart's calculation and
* manipulation tasks here in this 3rd attribute of the class (Cart).
*/
// I'm going to leave this constructor blank for you to fill in your own things!
// your application may need more features and you may need to use this constructor!
// this cart class is a generic barebone class that you can build upon it to make
// your ecommerce application more robust and powerful!
public function __construct()
{
// not implemented for this example! it's not needed for this example!
}
public function getNbLineItems()
{
// returns the number of items in the cart
return count($this->item);
}
public function getTotalWeight()
{
$totalWeight = 0;
foreach ($this->item as $id => $value)
{
$totalWeight = $totalWeight + ($value->qty * $value->getWeight());
}
// this function returns the total weight of all of the items in the cart
return $totalWeight;
}
public function getTotalItem()
{
$totalItem = 0;
foreach ($this->item as $id => $value)
{
$totalItem = $totalItem + $value->qty;
}
// this function returns the total number of all of the items in the cart
return $totalItem;
}
public function getTotalPrice()
{
$totalPrice = 0;
foreach ($this->item as $id => $value)
{
$totalPrice = $totalPrice + $value->extendedPrice();
}
// this function returns the total prices of all of the items in the cart
return $totalPrice;
}
public function setItemQty($id, $qty)
{
if ($qty == 0)
{
$this->removeItem($id);
}
else
{
$this->item[$id]->qty = $qty;
}
}
public function isEmpty()
{
// return true if the total number of all of the items in the cart = 0
// in other words, return true if no items in the cart
return ($this->getNbLineItem() == 0);
}
public function addItem($id, $qty, $product)
{
// if item exists, it is an old item, so simply update the qty to it
// else, it is a new item, so add this new item to the cart
if ($this->getItemQty($id) > 0)
{
$this->setItemQty($id, $qty);
}
else
{
$this->item[$id] = new Item($qty, $product);
}
}
public function removeItem($id)
{
// if there is an item (with this $id) in the cart, remove it
// remember that $this->item refers to all of the items in the cart
if (!$this->isEmpty())
{
$tmp = array();
foreach ($this->item as $idList => $value)
{
// if an item in the cart is not the item with this $id, then put it in $tmp
if ($idList != $id)
{
$tmp[$idList] = $value;
}
}
// store all of the items that are not the target of the deletion
// in other words, the deleted items are not stored in $this->item anymore!
$this->item = $tmp;
}
}
public function hasDiscount()
{
// iterating over all of the items in the cart to see if any item has a
// discount attached to it, then return true!
foreach ($this->item as $id => $value)
{
if ($value->discount > 0)
{
return true;
}
} // end foreach
return false;
}
public function removeAll()
{
// by initializing the variable $this->item to equal to an array() function,
// it erases the variable 'item' to equal to null! or equal to an empty array!
$this->item = array();
}
} // end class Cart
/**
* Usage:
*
* $cart = new Cart();
*
* $catalog is an array containing a catalog list of items for sale
*
* you pass in an id and a qty that you want to purchase available in the catalog
* that you pass in as well!
*
* this is mimicking a person looking at a catalog full of items for sale and choosing
* an item id and the qty to purchase.
*
* that's what this line of code (below) does!
*
* and that's what this class 'Cart' does!
*
* $cart->addItem($id, $qty, $catalog[$id]);
*
* of course, you have to use session in the addItem() call in order for it to persistence
* the session!
*
* this is a very elegance way to program a shopping cart by providing a lot of different catalogs
* with different kinds of items and depending on what a particular shopper is looking at which
* catalog, you pass that catalog to this function 'addItem'.
*
* you normally do your cataloging coding logic in the "external" controller to select and switch
* which catalog to pass in to function 'addItem'.
*
* if you implement your session properly in the addItem() call (in controller) it will persist the session for you!
* $cart = new Cart(); // this is should be in the external controller
*
* the call to $cart = $cart->addItem() adds the items in the array variable $item (or referring to as $this->item)
*
* $base->set('cart', $cart); // you need to persist the session as well!
*
* then in the view, you can iterate through the array variable $item using foreach(), for example:
*
* $cart = $base->get('cart'); // assuming you have $base as an instance of class Base
*
* foreach ($cart->item as $id => $product)
*
* with $id being the product id contains in the catalog!
*
* and $product being the product/item profile: product name, price, description, url, image, etc.
*
* from this basic generic guideline you should be able to build a very sophisticated ecommerce
* application, large or small easily and powerfully!
*
* there you have it!
*
* and have fun at it!
*/
?>
As you can see from the above example, you can have all kinds of catalogs displaying to shoppers and when a shopper selects a particular item, your "external" controller should be able to detect which catalog is being used. There are lots of ways to implement that feature and one of them is to send it in a form that contains the item profile along with the catalog name. For example:
<?php
/**
* for the form's 'action' attribute it contains a route called 'cart/add'
* this will route to a controller class called Cart and its method called add.
*
* of course, you have to implement it in an MVC scheme or else change it to: cart.php.
* id being the product id
* qty being the product qty that a shopper is buying
* catalog is the catalog name that the shopper is buying the product from
*/
<form action="cart/add" method="post">
<input type="hidden" name="id" value="<?=$id?>" />
<input type="hidden" name="qty" value="1" />
<input type="hidden" name="catalog" value="<?=$catalog?>" />
<input type="submit" name="submit" value="Add to cart" />
</form>
?>
As far as the catalogs are concern, they are basically arrays of items/products that contain the product profile or attributes: product name, id, price, description, url, image, etc.
How you implement that catalog feature is up to you. One way is to store catalog items in the database and then query the database to pull the catalog items and then put them in the array and then displaying them in your catalog/website for shoppers to view/purchase.
The possibilities are endless, the sky is the limit!
There you have it!
Have fun programming sophisticated eccomerce platforms and don't forget to thank me later!!!
A developer - also known as a programmer, coder or software engineer - is an IT professional who uses programming languages to create computer software.
What do software developers do?
Developers write, test, debug and maintain applications. Developer roles can vary widely depending on the type of organization. They are usually employed by either the technology companies that create off-the-shelf software or by end-user organizations - both in the public and private sectors - who develop bespoke applications. But coding, as we will see below, is just one important element of an increasingly broad role.
What skills do you need to become a software developer?
To answer that, here is an article by Mark Samuels that appeared on ZDNet which tells you everything about the programmer role and how it is changing.
Developers need strong technical aptitude. Some programmer positions will require a degree in a relevant field such as computer science, information technology, mathematics or engineering. While education is important, the fast-evolving nature of software development means on-the-job experience will be the key to successful career development.
What programming languages do software developers use?
Software development is a constant work in progress. The 2020 Harvey Nash Tech Survey found that a third of developers believe their current skills will only be relevant for the next three years.
Right now (as of the decade of 2020), JavaScript is the most popular programming language with 13.8 million developers, according to SlashData. The UK firm estimates that the JavaScript community accounts for a big chunk of the 24.3 million active developers worldwide.
SlashData says the second largest population of 10.1 million developers are Python users, which is popular with machine-learning specialists, while there are now 9.4 million Java developers. These top-three programming languages are the same as developer analyst firm RedMonk's rankings, which are based on data from GitHub and Stack Overflow.
Other popular programming languages include C/C++, C#, PHP, Kotlin, Swift, Go, Ruby, Objective C, Rust and Lua.
Language popularity can be cyclical. Take the recent re-emergence of Fortran in Tiobe's programming index at 20th position, up from 34th spot a year ago. Fortran emerged from IBM in the 1950s but remains popular in scientific computing.
What makes a good software developer?
Rob Grimsey, director at recruiter Harvey Nash, says there are many attributes to a good developer - and inevitably 'good' means different things to different organizations.
"What everyone will look for as a base requirement, of course, is a high degree of technical capability, founded on solid coding principles and the ability to work well in a variety of development environments," he says.
However, there's a further dimension to being a good developer that goes beyond a strong grasp of coding languages. Grimsey says a good developer is part of a team, especially with the modern focus on Agile software development. Agile is a set of collaborative methods and practices for producing software code faster and more efficiently.
"Developers might be involved in a daily stand-up and other interactions. The ability to communicate, contribute ideas, and understand the wider business context of the organization's requirements - all of these are crucial. Developers are having to play a more interactive role and help bring ideas to life," says Grimsey.
What's the demand like for software developers?
The simple answer is high. Skills shortages were bad enough before the pandemic - and Harvey Nash reports demand continues to outstrip supply today, especially in software development, cybersecurity, and data. "There is high demand for developers and it seems to be getting higher all the time," confirms Grimsey.
Take job listings for PHP, which is a commonly used but not particularly loved programming language. The number of entry-level PHP developer roles has increased a massive 834% since January 2020, making it the fastest-growing tech job across the industry, according to Indeed's data.
When the first UK lockdown began in March, Harvey Nash saw a pause in recruitment for many kinds of roles - but not for developers. Grimsey say developers were essential in enabling businesses to go through rapid digital transformation. Companies used collaborative technologies to tap into a wider talent pool from around the globe. However, the battle for talent remains fierce.
"Businesses have realized as a result of COVID, and the new remote-working model, that they can recruit from a much wider geographic spread, which is positive. But even so, that doesn't solve the problem. If you're a good developer looking for work, you shouldn't be looking for very long," he says.
What's the demand like for software development training?
Once again, the answer is high. Computer programming and software development were the top choices for people looking to improve their employment opportunities in 2020, according to technology firm Red Hat, with almost one in 20 adults taking up coding or some form of software development training last year.
Expect demand to continue to rise as we leave lockdown. The new normal of work will bring a lot of changes, but one enduring theme will be upskilling and learning new programming language tricks, with many of the most popular courses - from specialists like Coursera, Udemy, Pluralsight and Udacity - available for free or with a subscription.
Industry experts suggest there is already evidence of software development skills spreading beyond the programming community. Warren Breakstone, managing director and chief product officer for data management solutions at S&P Global Market Intelligence, believes technical knowledge has become more widely accessible.
"The next generation of clients we have are coming out of school and they already know Python and R. Rather just knowing how to use Microsoft products, they're coming out with expertise and knowledge around these newer development methodologies, such as Python, which makes data, data analysis and data science far more accessible," he says.
How big a threat is low-code/no-code development to software developers?
The democratization of software development knowledge isn't the only threat to established coders. Emerging technology might well help to fill part of the IT skills gap in the form of no-code/low-code development tools.
The tools cut, as much as possible, the hands-on knowledge required to build software. Tech analyst firm Forrester predicts the low-code market will grow 40% annually to top $21 billion by 2022, while fellow analyst Gartner forecasts low-code platforms will account for 65% of all app development by 2024.
However, it's important to state that the end of hands-on development is far from certain. Sophisticated applications will always require a professional programmer's skills. And there is some hope that no-code tools can free-up developers to work on some of those higher-level business engagement tasks that senior managers are so keen for coders to assume.
"Low-code won't kill the demand for developers but rather will mean that they need multiple skills," says Harvey Nash's Grimsey. "They'll be looked to as problem solvers with full-stack capabilities. So they won't only be involved in writing code for the core application build, but ultimately the full journey of a piece of software or application."
What's the key to being a successful software developer?
Tarah Lourens, chief product and technology officer at property specialist Rightmove, is a former developer, so she understands the kinds of skills that will help talented software engineers stand out from the crowd. Like others above, she suggests coding is just a crucial jumping-off point for successful developers.
"I've always been passionate that the right mindset is less about the coding and more about what we are trying to apply this technology to," she says. "We need people who can find the right balance between building great code and delivering business outcomes. The more you can do that, the further you're going to go."
That's a sentiment that resonates with Boots CIO Rich Corbridge, who says that having an eye on innovation - and using your creative ideas to help solve business challenges - is likely to be a key marker for long-term software development success. That's certainly something he's seen during the coronavirus pandemic at Boots.
"Some of the best things that we've seen coming out in the past 12 months have been inspired by engineers sat around and going, 'What if we did this?' And that ranges from true coding of new stuff all the way through to the implementation of a tool like Adobe Audience Manager and considering 'what if we did something differently; what happens to the speed of the site or the ability to transact?'"
What roles can software developers move into?
The most obvious step is to senior programmer. As well as coding and testing, senior developers will start to work more closely with the business to identify their business requirements from software. This kind of engagement leads some developers into business analyst and possibly enterprise architect roles, where the emphasis is on investigating and developing an overall application strategy for the business.
Developers who get a taste for leading others can step into team leadership roles. Those who want to go further up the career ladder still can explore project management roles, where their experience of developing software can be used to help lead specific technology initiatives. What's more, the increasing use of Agile software development principles across the business means experienced developers with good engagement skills are likely to be in high demand.
How can software developers step up into more senior positions?
The key to stepping up is going beyond coding. Modern developers need to think about how their knowledge can help the business create value from technology. Boots' Corbridge says his organization tasks its senior developers with making sure the business gets the most from its vendor partners, such as Cognizant, TCS and IBM.
"We tend to have more of the lead engineer role leading those partners in what they do," he explains. "Our skill set is around being able to touch and see what's going on across the development of their products. People who have the capability to be close to the business and understand what the business needs, and where the product is going to keep us up to date."
Making the most of partners is not always a straightforward task. Like so many other modern organisations, Boots is keen to use Agile software development techniques. Corbridge says it's his senior developers' role to ensure that the software that his team and its partners produce can be adapted flexibly as business requirements change.
"If we're doing fixed-price deliverables in an Agile world, the two things don't make easy bedfellows. So trying to manage any of our partners to a fixed-time contract - but against an agile burn-rate framework, keeping on top of where that's going and how that's working - has been a big lead engineer-type role in the past 12 months or so," he says.
What's the pay for a software developer?
Glassdoor suggests the average pay for a developer in the UK is around £40,000 (for the current timeframe of 2020 to 2024), although rates and pay vary significantly with experience, skill and geography and as time moves into the future. Skill-training platform CodinGame suggests developers in the US are likely to command the biggest salary, with an average software engineer grossing $95,744 per year.
Coding specialist Stack Overflow reports that Scala is the programming language associated with the highest pay in the US, with an average salary of $150,000. Other languages with a salary of at least $120,000 include Go, Objective-C, Kotlin, Perl, Ruby, Rust, C, Swift, Haskell, Assembly, Bash/Shell/PowerShell, C++, Java, Python, and TypeScript.
What's the future of the software developer?
Despite ongoing evolution in coding techniques and the rise of no-code development, the role of software developer is not under threat - but it is changing. Harvey Nash's Grimsey says the role is becoming more consultative with more stakeholder-facing emphasis.
"It's a shift that's already begun - the role will be about a whole lot more than writing lines of code, with many complementary skills required," he says. "Developers may get more involved in discussing the brief with their client, fleshing it out and iterating ideas."
Rightmove's Lourens also recognizes this shift. She says successful software engineering is no longer about what languages you know and is more about how developers can apply their mindset and aptitudes to the challenges the business faces.
"Things are moving so fast now that at the time you're assessing somebody on a language, it's already changed - there's a new version. I think over time, successful software engineering will become more and more about somebody's mindset first and then about the specific technical skills they've got," she says.
"I think that should open up the industry, too. For so long, success in the technology industry has been about what exposure you've had and what systems you've built in what language, which immediately closes down the opportunities for people. So, from a diversity point of view, I think the change in mindset is also a potential enabler."
The W3 Consortium (W3C) is a group founded by Tim Berners-Lee in 1994 to allow Web developers develop interoperable technologies (specifications, guidelines, software, and tools) to lead the Web to its full potential. The World Wide Web was invented by Tim Berners-Lee in 1989.
Without this group, who knows what the Web standard would be today if each group (or technology company) develops their own seperate Web standard for all of us to use?
Remember the browsers war between Netscape and Microsoft in the 1990s? Two different technology companies wanting their own broswer standard to be adopted by users and the casualty of that war, which is being felt today and beyond, is that we have to program code using two different standards to port to both browser standards.
Since then, the W3C has taken the bull by the horns and basically sets most (if not all) of the Web standards we enjoy today. A very nice reprieve from the constant squabble of the old days.
The following lists the standard specifications set by the W3C.
CSS2: Cascading Style Sheets 2.1 Specification
Descriptions of all CSS specifications
It is typically being used by website owners who need to upload their website files from their local computer to a remote server that their website is hosting on. You can also use FileZilla to download files from a remote server that your website is hosting on as well.
So it is a file transfer application using an FTP file transferring protocol. So FTP is an acronym for File Transfer Protocol.
As always, lots of tutorials on this subject are available on the Internet, particularly on YouTube and elsewhere in HTML. So instead of actually doing a tutorial that can be found easily on the Internet, I'm going to just refer you to those tutorials and let you follow those tutorials instead. Why is there a need for me to do a tutorial that is readily available on the Internet? The answer is that absolutely no!
So here we go:
Here are brief summaries of steps on how to configure FileZilla client after you'd watched tutorials listed above and as well as having FileZilla downloaded and installed onto your computer.
Download the FileZilla onto your computer.
Once you've downloaded it, extract it using zip extracting applications like WinZip Express Zip WinRAR or WinRAR here! PeaZip
Collecting FTP Details
After you installed FileZilla onto your local computer, you now are ready for the transferring process. But first thing first, you need to gather the FTP details of your hosting account. Each hosting provider is different in how they layout their FTP information. For Hostinger users, the information is located in the hPanel's menu, under:
Files -> FTP Accounts
Most hosting providers have a dashboard area or webspace area where you can see options to choose to go into more specific tasks. For example, for my hosting provider, it has a dashboard that shows all kinds of options for me to choose. For example:
Here, when I click on an FTP Manager, it takes me to an FTP manager area where I can setup/create FTP accounts. In the FTP manager I can create an account by creating a username and a password. I will need these information that I created to be used in the FileZilla. Here is what the inforamtion in the FTP manager looks like:
Once you have an FTP information, you can use it to configure FileZilla. Now all you have to do is click on your FileZilla icon to open it and you'll see a screen that looks like the following:
As you can see in the diagram above, on the left side is for a local working area or section. This is where you can configure your connection information and selecting files or directories to upload to a destination on the right side. On the right side is a remote site or destination area to upload to.
In the above diagram, you can provide information to do a "quick connect" connection. However, I strongly suggest that you don't use a quick connect but instead go through a longer connect, which I will detail it for you. It will save you time later on. A quick connect doesn't remember your connection setting after your computer is turned off, while a longer connection will.
Here is for the longer and more efficient connection:
Click on "File" at the top left corner of the diagram shown above. The drop-down menu will reveal several options but you want to choose "Site Manager" option. A site manager screen should open up and should looks like the following:
Pay close attention to a section called "Select Entry" where all of your FTP accounts are to be created. In my case, I have four FTP accounts: one account to connect to a Monday-Sunday website FTP hosting account; another to connect to a Noon2Noon.NET FTP hosting account; another to a Postal FTP hosting account; and finally to a ZeroNilZilch FTP hosting account.
So in my case, I have four different hosting service providers; and therefore, I need to have four different entry names (Monday-Sunday, Noon2Noon.NET, Postal, ZeroNilZilch), each connecting to its individual FTP account.
So in your case, the "Select Entry" section and "My Sites" area should be empty because you haven't create a "New Site" yet.
To create a "New Site" entry name similar to the four shown in my case, click on another option called "New Site" down below at the bottom of the diagram. Once you click on "New Site" option, an entry inside the "Select Entry" under "My Sites" area will appear for you to enter an entry name similar to the four entry names that I've created.
Name your entry name any name you like. It's just a name to differentiate from one entry name to another.
Once you created an entry name, you need to configure FileZilla to connect to your FTP hosting account by hi-lighting an entry name similar to what is shown with ZeroNilZilch right now. As you can see, once you hi-light it, the entire diagram flickers and changes the configruation and reveals input boxes for you to enter an FTP information.
For example, for me, I hi-lighted or selected 'ZeroNilZilch' in the "Select Entry" section, and then to the right, I entered 'zeronilzilch.com' in the host box.
This information is obtained from my FTP hosting account created earlier. In your case, you can get this information and the rest of the FTP information from your FTP hosting account.
For port, I use 21, which is a common port for a shared hosting. All you need to know about port is that if you rent or use a free web hosting from any vendor, use port 21, because most likely they're shared hosting. All shared hostings use port 21.
For protocol, select FTP; for encryption select FTP over TLS (just like what it looks like on the screen); for logon type, use 'Normal'; for user (or username) enter the actual FTP username you got from your hosting vendor; likewise, for the FTP password.
That is it! Nothing else to enter. Very easy! Now all you have to do is click on the button "Connect" to connect to your FTP hosting server to begin the transfer process.
After you click on "Connect" it should looks similar to the partial diagram shown below. I show only partial diagram to avoid revealing my other information to the public. But this partial diagram should give you a good idea of how it works.
As you can see, it is very easy to use FileZilla.
Now since you've created your connection the longer and more efficient way, next time you need to connect to your FTP account, just open up your FileZilla application that should looks like the default view similar to the one that has a "quick connect" option on it (shown earlier).
Yes, that is the default view of FileZilla (shown earlier) allowing you to either do a "quick connect" or do a longer more efficient connect.
So since you went through a series of steps to do a longer and more efficient connect already, now all you have to do is click on one of two things:
First the hard way:
You can click on "File" at the top left corner of the diagram shown above. The drop-down menu will reveal several options but you want to choose "Site Manager" option.
A site manager screen should open up and should looks like the "Site Manager" diagram shown earlier. From there, all you have to do is hi-light an entry name to make it looks like the one shown on "ZeroNilZilch." This will activate your FTP account setting and ready to be connected to. Next, just click on the "Connect" button and it will try to connect to your FTP hosting account.
Well, that was somewhat the hard way. Sort of!
Now the easy way:
The same thing: you can click on "down arrow" or a drop-down menu just below "File" at the top left corner of the diagram shown above. The drop-down menu will reveal an entry name (or several entry names if you have more than one as in my case).
Now all you have to do is click on an entry name in the drop-down menu and a "Site Manager" showing your entry name is shown ready to be connected to your FTP hosting account. Next, just click on "Connect" button and it will try to connect to your FTP hosting account.
Once connected it should looks something like a partial diagram shown below.
Since it is a partial listing of the actual full view, you're not able to see all options you can do with the connection. You'll have to make use your FileZilla on your own from here on. It is very easy because all the hard part has been explained and now is just the easy part.
Well actually, you can see a somewhat full view of the default view shown earlier and you should get a good idea of how you can select a particular file or directory to upload to.
But briefly, as you can see from the above diagram, there are two parts: one on the left side contains your local file directories where you can select and upload them to the destination on the right side. Simple enough?
On the left, because of a partial listing, I am not able to show you that you can actually select or pull down a drop-down menu to select any directory from your local computer to upload to the destination on the right side. Yes, you can select or pull down a drop-dwon menu on the left side and select any directories or files to upload to the destination on the right side.
Likewise, on the right side, you can select (or pull down a menu--well, mainly select) a directory to receive the content being uploaded to it. In other words, to upload a file or files or directory or directories, you need to know where in directory destination you want to upload the content from the left side to on the right side. Self-explanatory!
Once you've selected the destination directory on the right, and then you can go ahead and upload the content on the left side by hi-lighting or selecting it and right-click it to reveal several options. One of the options is "upload" and select "upload" to upload it. Self-explanatory!
Likewise, on the right, you select a particular file or files or directory or directories by hi-lighting it and then right-click it to reveal several options. One of the options is "download" and click on it to download. Self-explanatory!
That is it! Have fun using FileZilla.
For a very good introductory tutorial on the Web, please check out the following tutorials:
The MVC Pattern: PHP, MVC and Best Practices The MVC Pattern and PHP, Part 1 The MVC Pattern and PHP, Part 2 The MVC Pattern: An Introduction to the Front Controller Pattern, Part 1 The MVC Pattern: An Introduction to the Front Controller Pattern, Part 2For a more advanced pattern methodology, please check out MVVM (Model-View-ViewModel). MVVM was invented by Microsoft for desktop programming in 2005 using event driven programming techniques.
MVVM was invented by Microsoft architects Ken Cooper and Ted Peters specifically to simplify event-driven programming of user interfaces, i.e., GUI applications. The pattern was incorporated into Windows Presentation Foundation (WPF) (Microsoft's .NET graphics system) and Silverlight (WPF's Internet application derivative).
MVVM is more suiteable for desktop programming than Web programming.
So if you're programming for the Web use MVC and if you're programming for the desktop use MVVM.
Advanced Pattern: The advantages of MVVM over MVC Advanced Pattern MVVM For Desktop: Model-View-ViewModel Design PatternFor a more advanced pattern methodology using MVC, please check out on the 'how to build your own framework':
Advanced Pattern in MVC: Code Your Own PHP MVC Framework Advanced Pattern MVC and PHP: A Beginner's Guide To MVC For The Web ProgrammingAn MVC is an acronym for Model View Controller.
It is a methodology to uniform the way people program applications. Remember that in programming, programmers tend to have their own unique way of doing things and that causes a lot of confusions, especially in a team work where programmers are working in the same project. There is no way of knowing what each programmer is trying to do in the same project. There is a compatibility issue.
There is no uniform pattern way of doing things; each programmer is doing things each his/her own way of doing things; for example, in a team work in the same organization working on the same project, one programmer puts data handling with the organization of that data while another programmer puts the same data handling with the displaying of that data to users; and the two programmers are completely oblivious to what the other programmer is trying to do.
This causes the finished product to be in-efficient, in-compatible, and not robust and not to mention the cost of having programmers to do other similar projects that take a long time to complete because of the codes are not re-usable.
So to be efficient, robust, scalable, upgradable, re-usable, and easy to maintain, it has to be a unique way of doing things for all programmers to understand and work in a uniform way so that all programmers can know systematically what the other programmers are doing in the same project, even if each programmer is located far away from each other and haven't seen each other's actual work.
To solve this issue, the MVC was developed.
To understand the concept of MVC, think of it in term of an organization mentioned above where there is a manager, some programmers, and the customers who want to get the application done.
The customer is the view presenting to the manager of what to be done, telling the manager the criterio of what need to be done. For example, the customer may wants the website that has ecommerce and social media applications capability installed in it.
The manager is the controller, handling the organization (or criterio) of the task dictating and given by the customer.
The programmers are the model handling of data or instructions given by the manager and using those instructions from the manager to proceed to do all of the programming work.
Notice that the manager, or the controller, does not know how programmers perform their tasks for the project: he/she doesn't care how their programmers do their jobs as long as their programmers perform the task that meets the criterio given to them.
Likewise, the programmers know nothing about who the customer is and what he/she looks like or wants. The programmers don't really care who the customers are; all they care about is getting the task done.
Likewise, the customer knows nothing about who the programmers are and what they look like or where they're at or from. The customer only cares about is getting the website completed in the agreed timeframe.
And also, the programmers don't know how the manager got the instructions or whom he'd or she'd got it from. The programmers don't know what the heck the manager is doing either: the programmers just don't care what the manager is doing or how he/she is doing. It's not their job to know what the manager is doing.
Keep this seperation of concern in mind when you're dealing with MVC pattern.
As you can see, the three parties are completely independence of one another: in other words, they don't need to know what the other is doing or how the other is doing things. They all can do things in their own seperate unique ways without intertwine with one another.
Now imagine you're a large or small organization where you have lots of programmers working on all kinds of applications large or small and those programmers are spreading all over the world.
If all these programmers know MVC pattern, they can work on the same projects in different part of the world without knowing what the other programmers are doing on the same projects that they're working on.
This is the beauty of an MVC pattern where one group of developers working on the same project as the other group is located in far away from each other and they still can accomplish the same project without knowing what the other groups are doing.
In an MVC pattern, each party is seperate from one another and each party knows nothing about what the other party is doing. In an MVC pattern, each party doesn't need to know what the other party is doing as long as each party is doing its job in a unique/uniform way using MVC pattern.
Let's review: the customer requests to the manager telling the manager of what kind of application needs to be done; the manager, in turn, tells the programmers what tasks need to be done. That is all! Nothing else!
The customer doesn't know what the manager or the programmers are doing as long as the application gets done; while at the same time, the manager doesn't need to know what the programmers are doing as long as the task of getting the application done; and likewise, the programmers don't need to know what the customer looks like and how that customer's exact words to the manager -- it doesn't matter.
When you approach to building an application in an MVC pattern, think of the above analogy -- it will help you a lot.
Think of the analogy above and relate it to this: The view V is the display page (or customer in this case); the model M is the data (programmer in this case); the controller C is the coordinator, organizer, delegator, dictator, controller (or manager in this case).
Here is a brief example on how to program in an MVC pattern.
As you maybe well know that an HTML page is just nothing more than plain HTML texts along with some anchor links, buttons, or forms. That's all an HTML page is. And that is the view V.
Typically, the index.php front page or a catalog page or an HTML form is the view 'V' rendering the page to the customers/users to allow customer/users to navigate through the pages looking to do/order things.
In the index.php front page or a catalog page or form, there should be some buttons or links for customers/users to navigate to the products or area of interest.
That's all the view 'V' is; nothing special: just HTML pages or forms that contain contents and buttons or links. Nothing else!
Now when a customer/user clicks on the button or link, it redirects the customer/user to another part of the website or sometimes to another remote site.
Now before it reaches another part of the website or another website remotely, it has to go through a controller 'C' (or a middle man or a manager in our case). It has to hand over the instructions to the manager to decide on what to do next. Logically, a manager will hand over the instructions to programmers to start performing the tasks.
Remember that the programmers are the model M who do all the heavy work. The model also known as the data.
In the case of a button or link, it contains a url to redirect to:
'http://www.example.com/index.php?site/controller'
Before I show you how to parse this url (above), I want to show you the server access command using .htaccess file. Put this file in the same directory as your index.php in the root directory of your project. This index.php file is typically called a starting script file.
This .htaccess file is for the server to read before each time a website is loaded. This is sort of the instructions for the server on what to do before loading the website. You can tell the server what to do before loading your website using Apache's mod_rewrite commands.
This is the hand over the instructions to the programmers using routes.
The .htaccess file controls a number of ways that a website can be accessed, blocked, and redirected. It does this using a series of one or more rewrite rules. These rewrites are made possible by Apache's mod_rewrite module.
mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like. For example, control how your querystring is formatted.
Open up your text editor and create a file called .htaccess and put the following content inside it.
File: .htaccess
# please remove all these textual comments because it may cause problems!
# the .htaccess file starts with this line
RewriteEngine on
# the above line says turn on the Apache server
RewriteBase /
# the above line says look for content after http://www.example.com/
# with '/' being the last '/' after '.com'
# next two lines say if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# with !-d for a directory and !-f for file
# otherwise forward it to index.php (using the rule shown below)
# in other words, if none of the two conditions above is met or true,
# go to execute index.php, with index.php being the starting script file, i.e.:
# http://www.example.com/index.php
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
# continuing on above line: after the 'index.php?' is the querystring
# this is like: ?controller/action/param1/param2/para3/para4/para5/...
# so this string: url=$1 [L,QSA] is just for the server to read!
# the "L" stands for link, the Q for query, S for string, A for append
# the string "url" is the name of the querystring that you will need to
# refer to when you parse your route. see function splitUrl() later on!
# the below two lines are just more rules and server options
# the first allow json file to go through and the second for options
RewriteRule \.(json)$ - [F]
Options -Indexes
# you don't need to understand any of this content in this file
# just use it "AS IS" but don't forget to remove my textual description!
# one important note: don't forget to remove the RewriteBase / entirely
# if for some reason your website doesn't load!
# I found that for some shared hosting it causes a problem!
# so if it doesn't load, just remove the RewriteBase / entirely
# for more on this topic, please Google the Web and there are
# plenty of tutorials on the Internet on the topic of .htaccess file!
What the above .htaccess file does is allowing you to do like this on your url route:
<a href="http://www.example.com/controller/action/param1/param2/param3/...">link</a>
or just:
<a href="controller/action/param1/param2/param3/...">link</a>
Normally you would have to send your "GET" url string like this:
<a href="http://www.example.com/?controller=site&action=signup¶m1=value1¶m2=value2¶m3=value3&...">link</a>
The above link will route the route to the class SiteController with 'site' is the controller 'C' and 'signup' is the action or the method in the class SiteController. The rest are just "GET" method querystring parameters.
But with the .htaccess file you can do a shortcut to make your life easier by using URL rewriting rules or mod_rewrite rules.
So this is without URL rewriting rule: <a href="http://www.example.com/?controller=site&action=signup¶m1=value1¶m2=value2¶m3=value3&...">link</a>
This is with URL rewriting rule: <a href="http://www.example.com/site/signup/value1/value2/value3/...">link</a>
or just a shortcut:
This is with URL rewriting rule: <a href="site/signup/value1/value2/value3/...">link</a>
As you can see, it is much simplier using URL rewriting rules in the .htaccess file.
For img:
<img src="image/picture_1.jpg">
Notice that for img tag, there is no route needed. The img tags are typically being used in the view to display images; and therefore, routes are not needed. So you simply specify the src attribute that points to the directory of the image as you normally do in a non-MVC way.
For forms:
<form method="GET" action="http://www.example.com/site/signup/param1/param2/param3/..."></form>
Or just:
<form method="GET" action="site/signup/param1/param2/param3/..."></form>
For buttons:
<button type="button" onclick="http://www.example.com/site/signup/param1/param2/param3/..."></button>
Or just:
<button type="button" onclick="site/signup/param1/param2/param3/..."></button>
Basically, instead of having to write a complete route of
<a href="http://www.example.com/site/signup/param1/param2/param3/...">link</a>
on every link that you need, all you have to do is write just the querystring:
<a href="site/signup/param1/param2/param3/...">link</a>.
That's what the .htaccess file is for: allowing you to do a shortcut!
You will often route your form like this:
<form action="http://www.example.com/user/signup/param1/param2/param3/..." method="GET">
Or in a shortcut like this:
<form action="user/signup/param1/param2/param3/..." method="GET">
to route your user to the signup page. Notice that this is for a "GET" method. For a "POST" method see below.
The user part is the controller 'C' and the signup is the action. The rest are just "GET" method querystring.
If it is user/signup/id/guest/vip/ then user (the first part is always the controller 'C' and the second part signup is always the action, and the rest are extra GET parameters or querystring to send to the route.
In this case, there are three extra parameters that are being sent to the route: id, guest, and vip.
Please check out tutorials on the Internet to learn all these terms. Please check the following tutorial for more:
The MVC Pattern and PHPThe two most important terms are controller and action. Make sure you know what these two are and how to use them.
Hint: the controller is the class and the action is the method of the controller class. For example: user/signup.
<?php
// this is the controller
class User
{
// this is the action
public function signup()
{
// method code
}
}
?>
Note that you can use "POST" method as well and it will route your route via a "POST" and not via a "GET". For example:
<?php
<form action="user/signup" method="post">
<input type="hidden" name="id" value="My_id_123">
<input type="hidden" name="guest" value="This is the guest content">
<input type="hidden" name="vip" value="This is the vip content">
<input type="submit" value="Submit">
</form>
?>
The above form sends the POST variables to the route: user/signup. The .htaccess file routes this request through a normal HTTP REQUEST channel using a POST method.
DO NOT add the querystring in the POST method like you do with a GET method.
This is illegal: <form action="user/signup/id/guest/vip/" method="post"></form>
This is the correct way:
<?php
<form action="user/signup" method="post">
<label for="id">Enter your id:</label><br>
<input type="text" name="id" value="My_id_123">
<label for="guest">Enter your name:</label><br>
<input type="text" name="guest" value="This is the guest content">
<label for="vip">Enter your vip number:</label><br>
<input type="text" name="vip" value="This is the vip content">
<input type="submit" value="Submit">
</form>
?>
Remember that you handle a POST request the usual way where you send it to; for example, in the above case, it sends to the controller or class 'User' to execute the method signup(). Somewhere in the class 'User', particularly in the method signup(), is where you handle the request by doing this: $_POST['id'], $_POST['guest'], $_POST['vip'].
The keyword here is 'somewhere' because as you know the HTTP REQUEST once it is sent, it is available everywhere. So for class 'User', it is available everywhere inside it. Self-explanatory!
Now we need to parse the route or querystring.
This is also part of the handover of the instructions to programmers. Remember that managers only coordinate, delegate, and dictate the tasks to employees and do very little work.
<?php
// don't forget to put this class route in the folder: path/to
// or put it in whatever folder names you name them!
// 'path', 'to' are actually folder names containing the models or classes
namespace path/to;
class route
{
public $base = array();
// now your main controller class will need to call
// this method init()
// you can do it inside your index.php starting file or from
// inside your main application file, for example:
// $route = new route();
// $route->init();
// for an example of a starting script file, see my other tutorial
// called "how to autoload classes using SPL" and there is an
// index.php file example shown at the very end of that tutorial!
// see a lengthy explanation of the difference between an
// index.php starting script file and the index.php/index.html
// front page view [below]!
public function init()
{
// class Base is the base controller class
// I haven't written it yet! Maybe I won't!
// did I mentioned that this is a very brief tutorial?
// this will not be a complete tutorial! just to give you
// an idea to move forward!
// check out the Internet on topic of "MVC" base controller class!
// basically, the "controller base class" is the main application
// class that handles all the logic of the entire application.
// see an example in my other tutorial called
// "how to autoload classes using SPL"
// manager coordinates, delegates, and dictates the tasks to employees
$this->base = new Base();
// get the url fragments from the url
$this->splitUrl();
// you need to require/include the appropriate file directory
require_once 'resource/dispatch/dispatcher.php';
$dispatch = new dispatcher();
// basically test to see if the url fragment in $x1 exists!
// suppose that a visitor of your website types in the
// url bar: example.com and the browser will try to
// to load: http://www.example.com/index.php
// now when it gets to splitUrl() it will return:
// $x1 is null, $x2 is null, $x3 is null, etc.
if (!isset($this->base->x1))
{
// so it comes here because $x1 is null!
// it will load the default file index page!
// don't be confused the default index page file with
// the starting index.php file!
// the two are completely different from one another!
// the default index.php/index.html page is your index
// front page typically can be found in the view, while
// the starting script file index.php is the file to
// jumpstart the application!
// for an example of the default index.php/index.html
// front page, see class dispatcher->init()
// where the code that looks like this:
// manager coordinates, delegates, and dictates the tasks to employees
// basically the manager is handling the finished product to the customer
// for inspection to see if it fits the requirement!
// $this->base->render('index');
// as you can see, the statement above renders the view's
// index file: index.php/index.html in the 'view' folder!
// that's what the statement below is doing!
$dispatch->init();
// for an example of the script's index.php starting file,
// see my other tutorial called "how to autoload classes using SPL"
// and at the very end of that tutorial,
// there is a script file called index.php
// this script index.php starting file should be at the root
// of your application!
// if you look in my other tutorial called 'getting started
// programming for beginners', there is a section called
// 'How to Install WAMP on Windows', particulary, step 10.
// At the very end of that section where I show a
// localhost containing a sample application folder called
// "MyFirstWebsite"
// inside that folder there are only three items: 'css' folder,
// 'image' folder and the main starting script file 'index.php'
}
elseif (method_exists('dispatcher', $this->base->x1))
{
// now here, $x1 is NOT null!
// this is the case where you can do in the view like this:
// <a href="about">About</a>
// <a href="affiliate">Afilliate</a>
// <a href="signup">Signup</a>
// <a href="login">Login</a>
// remember what a view is?
// a view "V" contains only three main things: a page (i.e. webpage,
// catalog page, form, etc.), some links, and some buttons!
// that's all a view is
// the above example will load the controller page:
// dispatcher->about(), dispatcher->affiliate(),
// dispatcher->signup(), dispatcher->login()
// now what happens if you put an index "home" link/route in
// the view like the following?
// <a href="index">Home</a>
// here, x1 = 'index' but there is no method called 'index'
// in the 'dispatcher' class!
// so it won't come here and it will fall into the default
// condition below and displays the 'index' home page!
// now what happens if you put a link/route in the view
// like the following?
// <a href="user/signup">Signup</a>
// <form action="user/signup"></form>
// <a href="user/signup/id/guest/vip">Signup</a>
// <form action="user/signup/id/guest/vip"></form>
// obviously, x1, x2, and x3, etc, are not null!
// and therefore, it will still come here as well with:
// $x1 = 'user'
// $x2 = 'signup'
// $x3 = 'id'
// $x4 = 'guest'
// $x5 = 'vip'
// in this case, only x1 and x2 are relevant and both will be
// dispatched to the appropriate controller.
// see class dispatcher->user() later on!
$method = $this->base->x1;
$dispatch->$method();
}
else
{
// this is the default condition!
// if none of the conditions above are met,
// it will load the default index.php page!
// now what happens if you put a link/route in the view
// like the following?
// <a href="index">Home<></a>
// <a href="unknown">Unkown Link</a>
// <a href="noroute">Not Sure</a>
// all will come here because x1 = index, unknown, or noroute
// and x2 is null!
// so none of the conditions above are met,
// so all three cases above will come here and
// load the default index.php page!
// note that for your "Home" link, you can use the domain name
// as well (your domain), for example:
// <a href="http://www.example.com">Home</a>
// I recommend that you use the domain name for your "Home" link
// to avoid problems!
// if you use index or other unknown/undefined method of the
// controller (as shown above), it might give you an error saying:
// "Can't load the page! Please check your url to make sure it is
// the correct link!"
// so using the domain name as your "Home" link ensures that it
// will load the default index.php page every time! no errors!
$dispatch->init();
// now what happens if you put a form route in the view
// like the following?
// <form action="unknown"></form>
// <input type="hidden" name="test" value="some test value">
// </form>
// it will come here also because x1 = unknown, and x2 is null!
// here is the problem: the browser is confused!
// some browsers will load the default index.php and some browsers
// don't know what to do and display an error: Can't load the page!
// notice that we're talking about forms and not anchors!
// so the browser is confused!
// if it is an anchor it is probably okay and not confused!
// to solve this problem, for forms use the correct route:
// user/login, cart/addtocart, etc.
// so be aware of these scenarios!
// in other words, make sure you specify the correct route/link!
}
}
// handling the incoming instructions from the view!
// if the controller exists then call the controller
// also store the properties in the main application object to
// be used later: $this->base->x1
public function splitUrl()
{
// if you look in the .htaccess file you'll see this:
// RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
// check if the url GET parameter is set
// now the 'url' part is where we test for!
if (isset($_GET['url']))
{
// load the url into url variable
$url = $_GET['url'];
// trim the url to remove slashes on right:
// user/signup/id/guest/vip/
// becomes:
// user/signup/id/guest/vip
$url = rtrim($url, '/');
// break the url into fragments:
// $url[0] = 'user', $url[1] = 'signup', $url[2] = 'id',
// $url[3] = 'guest', $url[4] = 'vip'
// what happens if a user types in the url bar like:
// http://www.example.com ?
// splitUrl() will try to split the GET parameters and $url is null!
// in other words, splitUrl() cannot split the GET parameter:
// there is none!
// and the foreach ($url) loop below will return null as well!
// and therefore, x1, x2, x3 also will be null!
// now what happens if you put a link/route like the following?
// <a href="about">About</a>
// <a href="affiliate">Afilliate</a>
// <a href="signup">Signup</a>
// <a href="login">Login</a>
// it will split the url and $url contains an array of one element:
// $url[0] = 'about'
// $url[0] = 'affiliate'
// $url[0] = 'signup'
// $url[0] = 'login'
// and therefore, x1 = 'about', 'affiliate', 'signup', 'login'
// and x2 and x3 are null!
$url = explode('/', $url);
// load the url fragments as the object property variables
// as x1, x2, x3 ....
// in other words, set the main application's properties!
// notice that in PHP, you can declare a property on the spot
// and set it on the spot as well! very neat, huh?
// this is exactly what happens in the method set() below!
// you need to write a set($property, $value) in your main
// application controller class (Base) as well as a get()
//
// put the following two methods in your main base controller
// public function set($property, $value)
// {
// $this->$property = $value;
// }
//
// usage get():
//
// $base->get('x1');
//
// will return the controller, i.e.: user
//
// public function get($key)
// {
// if (isset($this->$key))
// {
// return $this->$key;
// }
// else
// {
// return null;
// }
// }
foreach ($url as $key => $value)
{
$key++;
// this is basically setting class Base's properties
// so that we can use them later. see init() above!
// later, anywhere, we can do this:
// $base->x1, $base->x2, $base->x3
// this will become:
// x1 = $value, x2 = $value, x3 = $value ....
$this->base->set('x'.$key, $value);
}
} // end if (isset($_GET['url']))
} // end splitUrl()
} // end class route
?>
Next is the dispatcher to dispatch the controller to the correct external controller.
Remember that there are two forms of controller: internal controller and external controller.
In this case, the internal controller are the class route and class dispatcher.
The external controller are the controller that actually doing the actual request to the model and as well as dictating to the view to display the view.
If you look in the method "user()" of the controller class "dispatcher" below, it creates an external controller by calling the createController() to create an external controller.
This is the manager who dictates to the programmers.
Remember that the manager only coordinates the job and doesn't do any heavy work at all! The heavy work is being done by the programmers.
As you can see below, the manager only asks the programmers to hand over the work by doing this: $base = new Base(). Now the manager knows nothing about what the programmers are doing inside class Base.
Now programmers all over the world can get to work on classes in their own seperate unique ways and none of them need to know what the others are doing. This is the seperation of concern of an MVC.
This example only shows one class or model; however, in a normal project large or small, there are lots of classes or model to be built and those classes or model can be given to groups of developers all over the world. And each group can work independently of one another without needing to know what the other groups are doing.
<?php
class dispatcher
{
public $base = array();
// now class dispatcher's init function
public function init()
{
// this method only contains two lines!
$this->base = new Base();
$this->base->render('index');
// that's it!
// the above call to render() tells the view to render
// the actual file in the 'view' folder!
// it is the controller telling the view to display the page
// view!
// the above call to render() will render the default front page:
// resource/view/index.php or index.html
// here is an example of render()
// method render() renders the view.
// this render() is incomplete as of now because I want you to
// implement your own version of render to suite your objective!
// how you implement your version of render() is up to you!
// but I suggest that you implement it using only two arguments:
// $this->base->render($view, $template);
// with $template, you might find it very useful to send in,
// say, a theme, or even a model!
// how you do it, it's up to you!
// you can make improvements to this barebone render() to make it
// more robust and powerful!
// notice that render() below, $template is an array and is
// initialized to null and you can call it like this:
// $this->base->render('index');
// $this->base->render('contact');
// $this->base->render('about');
// $this->base->render('affiliate');
// below, the first argument is the page: index.php or contact.php
// the second argument is the template or theme page or model or
// whatever!
// notice that you don't need more than two arguments!
// put the following render() code in your main application
// base class similar to the example class Base()
// public function render($view, $template[] = null)
// {
// // setting the view template to default theme or whatever!
// // I won't show you the example and leave it for you
// // to implement in your own unique ways!
// // this "if" block needs more work to suite your objective!
// if ($template == null)
// {
// // set it to default theme or whatever!
// $template = 'default_theme';
// }
// // right here where you can branch out to different
// // view/files/themes
// // you can branch out to tidbits of snippets of code
// // view as well
// // right here, you can implement code that looks for
// // certain view and files that resides in a folder
// // it's a very good idea to implement code that can
// // handle view in its own folder.
// // that way you can put certain view in certain folders
// // for modularity purpose!
// // as stated earlier, how you implement your render()
// // is up to you!
// // but here is one possible way of doing it:
// // you implement your first argument that can receive
// // two items: view/index
// // with 'view' being the folder and index being the file!
// // you can call it like this:
// // $this->base->render('view/index');
// // $this->base->render('affiliate/index');
// // $this->base->render('about/index');
// // $this->base->render('profile/index');
// // OR
// // $this->base->render('catalog/index', $template);
// // $this->base->render('cart/index', $template);
// // $this->base->render('admin/index', $template);
// // $this->base->render('product/index', $template);
// // I won't show the latter case and leave it to you to do!
// // notice that you can add as many folder levels as you want, for example:
// // $this->base->render('index/folder1/folder2/folder3/folder4/', $model);
// // and explode them into:
// // $view[0] = 'index'
// // $view[1] = 'folder1'
// // $view[2] = 'folder2'
// // $view[3] = 'folder3'
// // $view[4] = 'folder4'
// // now let's illustrate the first case!
// // right here inside this render() you can do this:
// if (strpos($view, '/'))
// {
// $view = explode('/', $view);
// // now $view is an array of two elements: a folder and a file
// // $view[0] = 'view', $view[1] = 'index'
// // $view[0] = 'affiliate', $view[1] = 'index'
// // $view[0] = 'about', $view[1] = 'index'
// // $view[0] = 'profile', $view[1] = 'index'
// // from there, you can branch out to display the view from
// // its own folder!
// // as far as the second argument is concern, it is very
// // much can be anything: a theme or a model or anything!
// // right here where you refer to the view files
// // stored in the directory:
// $file = "resource/$view[0]/$view[1]" . '.php';
// if (file_exists($file))
// {
// require_once $file;
// }
// else
// {
// echo ("View file <b>resource/$view[0]/$view[1]</b>" .
// '.php not found');
// }
// }
// else
// {
// // you need to put all of your view files in the directory/folder
// // called 'resource/view' or whatever folder name you desire!
// $file = "resource/view/$view" . '.php';
// if (file_exists($file))
// {
// require_once $file;
// }
// else
// {
// echo ("View file <b>resource/view/$view</b>" .
// '.php not found');
// }
// }
// // as stated above you can add as many folder levels as you want, for example:
// // $this->base->render('index/folder1/folder2/folder3/folder4/', $model);
// // but that looks very awful and cluttered!
// // another way is to use some sort of label marker or flag to mark how many levels
// // of folders you are targetting for. for example:
// // if a label marker says 'index/flag1' you have only one level of folder,
// // if a label marker says 'index/flag2' you have only two levels of folders,
// // if a label marker says 'index/flag3' you have only three levels of folders,
// // if a label marker says 'index/flag4' you have only four levels of folders,
// // if a label marker says 'index/flag5' you have only five levels of folders,
//
// // that looks much cleaner and maybe better than the long list of folders example above.
//
// // and in the view pages you can do like these:
//
// // $this->base->render('index/flag1', $model);
// // $this->base->render('index/flag2', $model);
// // $this->base->render('index/flag3', $model);
// // $this->base->render('index/flag4', $model);
// // $this->base->render('index/flag5', $model);
// // of course, you can have other files as well beside 'index.php'
// // just replace your actual file name in place of 'index'
// // and inside this render() you can do this:
// if (strpos($view, '/'))
// {
// $view = explode('/', $view);
// // now $view is an array of two elements: a file and a folder flag where:
// // $view[0] = 'index' // which is a file: index.php
// // $view[1] = 'flag1' or 'flag2' or 'flag3' or 'flag4' or 'flag5'
//
// // after the explode(), these scenarios could happen.
// // I'm just showing the 1st argument to illustrate the example:
//
// // if render('index/flag1') ===> then $view[0] = 'index' and $view[1] = 'flag1'
// // if render('index/flag2') ===> then $view[0] = 'index' and $view[1] = 'flag2'
// // if render('index/flag3') ===> then $view[0] = 'index' and $view[1] = 'flag3'
// // if render('index/flag4') ===> then $view[0] = 'index' and $view[1] = 'flag4'
// // if render('index/flag5') ===> then $view[0] = 'index' and $view[1] = 'flag5'
// //
// // now we need to test the flag for the levels of folder after we exploded them:
// //
// // switch ($view[1])
// // {
// // case 'flag1':
// // $file = "view/$view[0]" . '.php'; // view/index.php
// // break;
//
// // case 'flag2':
// // // resource/view/index.php
// // $file = "resource/view/$view[0]" . '.php';
// // break;
//
// // case 'flag3':
// // // view/template/path/index.php
// // $file = "view/template/path/$view[0]" . '.php';
// // break;
//
// // case 'flag4':
// // // guide/local/dir/view/index.php
// // $file = "guide/local/dir/view/$view[0]" . '.php';
// // break;
//
// // case 'flag5':
// // // source/store/cabinet/top/view/index.php
// // $file = "source/store/cabinet/top/view/$view[0]" . '.php';
// // break;
// // } // end switch
//
// // now that looks a lot cleaner!
// // anyhow, there are lots of ways to do this kind of thing and there is
// // no right or wrong way of doing it!
// // from here, you can branch out to display the view from
// // its own folder! for example:
// // first test to see if our levels of folders exist including its file
// if (file_exists($file))
// {
// require_once $file;
// }
// else
// {
// echo ("View file <b>$file</b> not found");
// }
// } // end if (strpos($view, '/'))
// } // end render()
// ***** END OF RENDER() *****
// you'll have to create a file called about.php and put it
// in the autoload directory!
// see my other tutorial called "how to autoload classes using SPL"
// do the same thing for the rest of these files:
// this is the manager telling the programmers to handover the task!
// maybe more appropriately the controller telling the view to
// display the model or data!
// the model is the the data to display: about.php
// the route for this method is: <a href="about">About</a>
public function about()
{
$this->base->render('about');
}
// the controller telling the view to display the model or data!
// the model is the the data to display: affiliate.php
// the route for this method is: <a href="affiliate">Afilliate</a>
public function affiliate()
{
$this->base->render('affiliate');
}
// the controller telling the view to display the model or data!
// the model is the the data to display: signup.php
// the route for this method is: <a href="signup">Signup</a>
public function signup()
{
$this->base->render('signup');
}
// DIDO!
// the route for this method is: <a href="login">Login</a>
public function login()
{
$this->base->render('login');
}
// DIDO!
// the route for this method is: <a href="profile">Profile</a>
public function profile()
{
$this->base->render('profile');
}
// this controller class Dispatcher's purpose is to dispatch controller
// to their proper destinations!
// it also displays static controller actions like about, affiliate, signup,
// login, profile, etc., on the spot without having to dispatch them anywhere!
// in other words, it calls render() directly on the spot without having
// external controller doing the job!
// by doing this (and by the look of this controller class 'Dispatcher'),
// it is very cluttered if you have lots of conttollers/actions!
// it will make this class very hard to navigate and debug!
// so static controller