Sunday, 31 July 2011

Friendship Day Messages

Friendship Day Messages

This Friendship Day honour your friends and let them know how special they are to you with a cute and heartfelt Friendship Day Message. To enable you to reach out to your friends and also share the sweetness of your friendship with others we have dedicated this page to you and your friends. Send in a straight from the heart Friendship Message for your friends and we promise to post it on this Friendship Day Message page in this site dedicated to friendship.

Messages:

To Varsha,
If you open my heart, guess what u r gonna see? It's U. True friends are hard to find so I kept u.
From
Ash


Dear Friend,
FRIENDSHIP isn’t how U forGet but how U forGive,
Not how U liSten but how U UnderStand,
Not what U see but how U feel,
and not how U Let Go but how U hold oN!!!
HAPPY FRIENDSHIP DAY!!
From
Manisha


Dear Friend,
If u r a chocolate ur the sweetest, if u r a Teddy Bear u r the most huggable, If u r a Star u r the Brightest, and since u r my "FRIEND" u r the "BEST"!!!!!!!!!
From
Teja


To Neel
I am really very happy with my friend Neelima. I always treat her as my special friend throughout my life i thank god 4 givng me such cute friend i lov her very much i always want her to be happy forever i really lov her vry much. But wen u will not be with me my life will be like a hell so i want ur frndshp forever n ever love u always my sweet heart.
I love you forever Ashwini
From
Sheela


I thank and praise god for every memory of yours
You are stalwart and sunshine in the valley of life
May god continues to strengthen you with might
May He lights your path in every alley or night
And bless you with grace that is never ceasing.
Be my friend Ash (only in this life, because in our next life you know better what I want you to be)
I love you forever Ashwini
From
Neeraj Gupta


Hey Pinu,
Missing you so much. Always tried to being your best friend. But things not happened as I thought. May be we are far from each other. But I'll always be there for you & try to make things as we dreamed of!
From
Wanna B Best Friend


Hi,
I would like to wish my best friends Chaand, Aman and Deep. You guys are very nice and please don't forget me. I really really miss you all.
Your's best friend
Kapil Virdi


Sometimes, I forget to say hi,
Sometimes, I even miss to reply,
Sometimes, my message doesn't reach you,
But, it doesn't mean that I forget you,
I just giving you time to miss me!
Samir


First of all happy friendship day to all my friends. I believe there is no word in dictionary to express how good you feel when you have caring friends.
Shreepriya


Dear Ash,
I thank and praise god for every memory of yours
You are stalwart and sunshine in the valley of life
May god continue to strengthen you with might
May he lights your path in every alley or night
And bless you with grace that is never ceasing.
Be my friend Ash. (only in this life, because in our next life you know
better what I want you to be)
I love you forever Ashwini.
From
Gururaj Sharma


A good friend is like a computer. I 'enter' in your life, 'save' you in my heart, 'format' your problems, 'shift' you to opportunities & never 'delete' you from my memory!
Menaka


True friends will not have any reason for their friendship. So it can never be broken when they don't find that reason.
Kumaraswamy


Shona,
I just want to become the first friend of yours to wish you a very "Happy Friendship Day". I mean nothing to you, but you always mean everything to me. Thanks for coming in my life. I even don't know whether you have accept my request or not. But I will always be there with you and for you, forever.
Love you shona and missing u a lot.
From
Your's bewakoof friend


Hi bhabz, how are you. missing you all. How are shadiq and Sameer bhaiba? So when are you coming to savusavu? Just want to wish you a Happy Friendship Day in advance which is on the first Sunday of August. Give my love to my dearest shadiq and lots of love to you all.
Rizwana


Hi friends,
I am short of words to write anything. But in few words I would like to say.... May God give you all a lot of happiness and success...
Satish Khachane


Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Walk beside me and be my friend.
Kevin Subba


Hi Simacians,
Wish you all a very Happy Friendship Day! I miss you all a lot. Thanks for giving me your love and affection.
Love
Rakesh


Hi Vicky,
Sorry, if I ever hurt your feeling. But I really love you since you are one of my sweetest friends. I miss you all the time.
Love you & miss you so much.
Keep smiling forever.
Sweety


A single candle can illuminate an entire room. A true friend lights up an entire lifetime. Thanks for the bright light of your friendship.
Mahesh


I wish you a very "Happy Friendship Day" with more Love and God Blessings.
Mallika


Dear cory,
Hi i love your smell like a buttercup. You are nice and sweet and I miss you.
love
Sract Marryey


Hey Taylor
U mean the world to me and i just want to let u no i am making u a DVD :D lol well yea i can't wait till the summer when we spend time together all over again but it just makes us remember that highschool is almost here love u a lot
Chels


Dear Friends in India and Nepal,
I wish you all a very very happy Friendship Day. May our bond of friendship last till eternity.
Love you all
Ankur, Nepal


Hi Bhavisha, Neha, Henna, Reshmi, Shalini, Valencia, Melroy, Purvil, Mitul, Gayatri, Naina.....and anyone whom I have missed out....A Very Happy Friendship Day To You All... Hav Fun Coz it's our Day!!
From
Alden


Time & distance are important between friends. When a friend is in ur heart, they remain there forever. We may be get busy, but I assure u, u will always remain in my heart!.
From
Debarpan Chakraborty


I remember the days when u were with me. I remember everything like those surfings, those chats, those ice-creams, those chocolates... I remember the days of long drive at the speed 100 I remember those sharing n those joys but gone are those days. I really miss u my frnd. coz u r special to me.
From
Nidhi


Sonia,
In a very short time we have become very good friends. I shared great moments with you. We will become true friends. Wish you a very Happy Friendship Day.
From
Ritesh


Dear Mr. Caring
You've always been there for me. The wonderful moment we have spent together, sharing each others joys and sorrows… Thanks for spreading smiles everywhere and making my life so beautiful, meaningful and Happy…
My Dear Godan, I wish and pray that this bond grows stronger ever and ever..
by ur thangatchi
Aarthi


Hi Richa,
Happy Friendship Day. Thanx for being with me n making this Frndshp Day special for me. I hope our frndshp never ends.
I m always with u
Rohit Bhardwaj


Hi Jyotu!
A Very Happy Friendship Day! Pehli baar without each other but still going so strong. I love u and always will, no matter what.. We r best friends forever!! Love u n Miss u Jaan!
Teri,
Sukhu


Hi Akshita,
I want to wish u a HAPPY FRIENDSHIP DAY. I want to be the first one to wish u. May god bless my BEST FRIEND.
From
Kruti


Dear friend Suzan,
Advance wishes to you for the FRIENDSHIP DAY AUGUST 6TH 2006. We are really true friends forever. I would like to send you the friendship band, it will be on your table on monday.
Your loving friend
Sathya


Hello!
How are you my janoo I miss u becoz it's Friendship Day and u r not with me oh! but when i feel u in my heart then i thought that u are with me forever. I love you very much take good care of urself.
bye
Ali Rizvi


Hi Krit,
How are you i m missing you very much and i love you. HAPPY FRIENDSHIP DAY
From
Sudhir Anand


Dear Kiddo,
It's been 1 yr since we became friends and its our 1st friendship day. U r very special to me and I really enjoy ur friendship. Thanx for coming into my life.
Love,
Nats


Need I say anything to u? U were special to me and will always remain so. Celebrate FRIENDSHIP DAY WEEK.
From
Seema


I love all my frenz!! Just to let them know dat they are very spl to me!! Though I accept I'm bit careless in everything but they are very special to me!! Love them all!! Take lots of care in life. God bless ya all!!
To all my frenz --Simar, Swati, Pawan, Ardaman, Rajan, Preeti, Ashima, Parneet (plz forgive if I din mention ya name bt each one is spl!!
From
Tanu


Hai Selena,
Happy Friendship Day. U r a very nice friend. Thanks for ur friendship.
From
Lance Vijay


Knowing a friend like u has made me happy in a million ways. And if ever I have to let you go..I would find a million reasons to make u stay!!!
From
Harshil


Wish you a Veryyyy...HHHAAAAPPPYYY FRIENDSHIP DAY
My wishes in advance. Check this ...Is is cute? See how much do I care for my friend !!
From
Manvi Saxena


Hi Baku
Happy Frdship Day. u r my best frd so i am sending it to u. Always be with me through my life.
Luv u lot
Mittal


To Swathi
How long shall v b friends? Do u want a clue? As long as stars twinkle in the sky, till the water runs dry & till the day I die. We will b friends.
From
Kalpana


Hi Mahi
Wish U A Very Happy Friendship Day. Thanks A Lot 4 Being My Dearest Friend.
From
Ashish


This is a small message for u Naveen...
U R my BEST FRIEND!!!
From
Annie


Hi Neha,
Happy Friendship Day to U. May our friendship last till the existence of the earth.
From
Sachin


Dear Kavi,
May our friendship grow and create a milestone on friendship history......
Cheersssssssss...............
From
Gopu


Rahi badal jate hai par raste nahi badalate,
Toofan aaye fir bhi mausam nahi badalate
Gile shikawe bhale kitane ho
Magar sacche dost kabhi nahi badalate
From
Sweetu


Hi Rohan
A friend scolds like a dad, cares like a mom, teases like sister, irritates like brother.
Friendship is the blend of all relations.
Wish u a Happy Friendship Day.
With love,
Sri


Hi Joe,
Happy Friendship Day... Really u r the special one for me!
From
Rajesh


Sajti rahe khushion ki mehfil,
Har khushi suhani rahe,
Aap jindgi me itne khush rahen,
Ki har khushi apki diwani rahe.
Neeraj Lakhera


Woh nadiyan nahi aansu they mere, jinpar woh kashti chalate rahe.
Manzil mile unhein yeh chahat thi meri, isliye hum aansu bahate rahe.
Rajen Negi


Stacy,
Just wanted to say hi on Friendship Day you are my very best friend. We have been through so much and I will never forget it.
I love you and miss you so much
Bill


My Dear Girl...
U dont have 2 do anything at all 4 me. U came to me as a friend and a friend u'll alwiz be. U can put a smile on my face without doing nothing and I'll alwiz cherish u for that..
Love u alwiz
Umie


Sonam
I Love U more & more than anything else in the world.
HAPPY FRIENDSHIP DAY!!!
Sujit Kumar


To Honey, (Kanpur)
Wish you very Happy Frienship Day.
Your Friend
Apurv


Hi Buddies,
Friendship is an art in which no one can explain the meaning of the art fully.
From
Johnny


Friendship Has No End
Stars have 5 ends, squares have 4 ends, triangles have 3 ends, lines have 2 ends, life has1 end, but I hope r friendship has no end.
From
Praveen


Friendship is a golden knot in which two angles lie together and if you do not break it I will be your friend forever.
From
Shina


People win and people loose,but trust me on one thing, "YOU WILL NEVER LOOSE ME!!!"I will always be there for you.
From
Zana


Hi There Friend,
Have a great day in every way. You are a true friend and a friendship card is what I send.
From
Sharon Maness


A good friend is like a computer; I 'enter' ur life, 'save' u in my heart, 'format' ur problems, 'shift' u 2 opportunities & never 'delete' u from my memory!
From
Alok


Hi Shoye
This is my way of pleasing U. We were, are, and will be friends for ever.
From
Althaf


SIRI ADVANCE FD TO U....
True friendship is like sound health, the value of it is seldom know until it be lost. A real friend is one who walks in when the rest of the world walk out.
From
Suresh


Friendship is like a golden chain which links two hearts.
Altaf and Shoyeta are Best Friends forever.
From
Shoyeta


Dear Rithu
You have always been like a majestic flower who always grants me wishes and fills me with joy. Even though we are now apart our friendship stays forever at heart.
From
Rukmani


Blessings come in many ways but the best come as friends.
From
Leena Immanuel


To My lovely Teacher-Sonia Parmar
Just having you close;
Fills me with LOVE & HOPE;
Nothing is impossible with you by my side.
From
Shibani Shah (Vapi,Gujarat)


Gurjeet
Gurjeet,I Love You so much. I love you more than my life.
From
Inder


Dear Sunanina
Its been a long time since we actually met but you have never been away from my heart. I miss you everyday and cherish the times we spent together. Wish those sweet and golden days could come back and we could share jokes and laugh about carefree of everyday tensions in life...
Wish you many successful years ahead and a bright and happy days always:
Lots and lots of love
Juhi


Sweetest Friend Harini
I miss you so much. I miss the way we used to freak out and share ice-creams bunking classes. Every time I see anybody eating the Cornetto ice-cream, I imagine you eating that in that cute and peculiar style of yours. I hope you are doing fine in life and enjoying a happily married life.
Desperate to see you:
Yours Moti Kan


Dear Sir
It’s difficult to find people like you on this earth. I will always embrace you with purity and sincerity. I pay you my gratitude, my love, my devotion, my life and my soul.

Friend you are an unlimited storage of love, care, courage, compassion and strength. You are a treasured reservoir with unlimited virtues and morals within you. You are divine, an ocean of transcendental tasteful relationships, and an embodiment of eternal love.
With Love
Anamika


Hi Mahika
Wish you a Happy Friendship Day. You are my best friend and always will be. Wish you the very best in life.
Your Friend
Anika


MISS ANYTHING FOR FRIENDSHIP,
BUT
DO NOT MISS OUR
FRIENDSHIP..
BECAUSE
UR MY GOOD FRIEND..
Your Friend
Anika


TO DEAR ANUJA,
There is always a thing reserved for 'u',which niether u nor other can feel nor see,,,,but,,,but,,,i can feel for ever...and it's the real lovefor'u',dear.HAPPPPPPPPPPPPP..............................................Y FRIENDSHIP DAY. ALWAYS KEEP OUR RELATION IMMORTAL..
Your Friend
Swastika

Friendship Day Quotes

Friendship Day Quotes

Feel the essence and worth of true friendship with these golden Friendship Quotes. Coming straight from the heart of some of the most celebrated writes, personalities and loyal friends, these soft and sentimental lines on friends and friendship will make you think more fondly about your friends.

"Wishing to be friends is quick work, but friendship is a slow-ripening fruit."
~ Aristotle

"Friendship is essentially a partnership."
~ Aristotle

"Friendship makes prosperity more brilliant, and lightens adversity by dividing and sharing it."
~ Cicero

"Your friend is the man who knows all about you, and still likes you."
Friendship Day Quotes by: Elbert Hubard

"True friendship is like sound health; the value of it is seldom known until it be lost."
Friendship Day Quotes by: Charles Caleb Colton

"Each friend represents a world in us, a world possibly not born until they arrive, and it is only by this meeting that a new world is born."
Friendship Day Quotes by: Anais Nin

"My friends are my estate."
Friendship Day Quotes by: Emily Dickinson

"A real friend is one who walks in when the rest of the world walks out."
Friendship Day Quotes by: Walter Winchell

"A friend is someone who is there for you when he'd rather be anywhere else."
Friendship Day Quotes by: Len Wein

"A friend is someone who knows the song in your heart, and can sing it back to you when you have forgotten the words."
Friendship Day Quotes by: Unknown

"A friend is one who believes in you when you have ceased to believe in yourself."
Friendship Day Quotes by: Unknown

"Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Walk beside me and be my friend."
Friendship Day Quotes by: Albert Camus (also attributed to Maimonidies).

"A hug is worth a thousand words. A friend is worth more."
Friendship Day Quotes by: Unknown

"Everyone is a friend, until they prove otherwise."
Friendship Day Quotes by: Unknown

"Every person is a new door to a different world."
Friendship Day Quotes by: from movie "Six Degrees of Seperation"

"It takes a long time to grow an old friend."
Friendship Day Quotes by: John Leonard

"I get by with a little help from my friends."
Friendship Day Quotes by: John Lennon

"Anybody can sympathise with the sufferings of a friend, but it requires a very fine nature to sympathise with a friend's success."
Friendship Day Quotes by: Oscar Wilde

"Two are better than one; because they have a good reward for their labour. For if they fall, the one will lift up his fellow: but woe to him that is alone when he falleth; for he hath not another to help him up."
Friendship Day Quotes by: Bible: Ecclesiastes

"Two may talk together under the same roof for many years, yet never really meet; and two others at first speech are old friends."
Friendship Day Quotes by: Mary Catherwood

"Friendship is unnecessary, like philosophy, like art... It has no survival value; rather is one of those things that give value to survival."
Friendship Day Quotes by: C. S. Lewis

"I might give my life for my friend, but he had better not ask me to do up a parcel."
Friendship Day Quotes by: Logan Pearsall Smith

"Friends are the most important ingredient in this recipe of life."
Friendship Day Quotes by: Unknown

"The better part of one's life consists of his friendships."
Friendship Day Quotes by: Abraham Lincoln

"The love of my life is the love between friends."
Friendship Day Quotes by: Unknown

"One's best friend is oneself."
Friendship Day Quotes by: Unknown

"A Friend is someone who knows all about you and loves you anyway!!!"
Friendship Day Quotes by: Unknown

"To be depressed is to be lonely; to have a friend is to be happy..."
Friendship Day Quotes by: Guido

Friendship is like a perennial river which flows forever. It may change it's path but will never ever dry up.
Friendship Day Quote Contributed by: Pinaki Prasad Mohanty

Contemporary Quotes:

"The friendship that can cease has never been real."
~ Saint Jerome

"Well, it seems to me that the best relationships--the ones that last--
are frequently the ones that are rooted in friendship.
You know, one day you look at the person and you see something more
than you did the night before. Like a switch has been flicked somewhere.
And the person who was just a friend is...suddenly
the only person you can ever imagine yourself with."
~ Dana Scully (The X-Files)

Friendship involves man things but, above all the power of going outside oneself and appreciating what is noble and loving in another.
~ Thomas Huxley

Plant a seed of friendship; reap a bouquet of happiness.
~ Lois L. Kaufman

Friendship is the golden thread that ties the heart of all the world.
~ John Evelyn

"Friendship multiplies the good of life and divides the evil."
~ Baltasar Gracian

"Friendship needs no words..."
~ Dag Hammarskjold

"The most I can do for my friend is simply to be his friend. I have no wealth to bestow on him. If he knows that I am happy in loving him, he will want no other reward. Is not friendship divine in this?"
~ Henry David Thoreau

"Friendship that flows from the heart cannot be frozen by adversity, as the water that flows from the spring cannot congeal in winter."
~ James Fennimore Cooper

"Friendship without self interest is one of the rare and beautiful things in life."
~ James Francis Byrnes

"I keep my friends as misers do their treasure, because, of all the things granted us by wisdom, none is greater or better than friendship."
~ Pietro Aretino

"The rain may be falling hard outside,
But your smile makes it all alright.
I'm so glad that you're my friend.
I know our friendship will never end."
~ Robert Alan

"Let there be no purpose in friendship save the deepening of the spirit."
~ Kahil Gibran

"Friendship is a strong and habitual inclination in two persons to promote the good and happiness of one another."
~ Eustace Budgell

"Friendship is Love without his wings!"
~ Lord Byron

"In the sweetness of friendship let there be laughter, and sharing of pleasures."
~ Kahil Gibran

"True friendship is like sound health; the value of it is seldom known until it be lost."
~ Charles Caleb Colton

"Every man passes his life in the search after friendship."
~ Ralph Waldo Emerson

"We cannot tell the precise moment when friendship is formed. As in filling a vessel drop by drop, there is at last a drop which makes it run over; so in a series of kindnesses there is at last one which makes the heart run over."
~ Samuel Johnson

"However rare true love may be, it is less so than true friendship."
~ La Rochefoucauld

"Love is rarer than genius itself. And friendship is rarer than love."
~ Charles Peguy

"There can be no Friendship where there is no Freedom."
~ William Penn

It is not what you give your friend, but what you are willing to give him that determines the quality of friendship.
~ Mary Dixon Thayer

One of the surest evidences of friendship that one individual can display to another is telling him gently of a fault. If any other can excel it, it is listening to such a disclosure with gratitude, and amending the error.
~ Edward Bulwer-Lytton

The language of friendship is not words but meanings.
~ Henry David Thoreau

True friendship is a plant of slow growth, and must undergo and withstand the shocks of adversity, before it is entitled to the appellation.
~ George Washington

Friendship is to be purchased only by friendship. A man may have authority over others, but he can never have their hearts but by giving his own.
~ Thomas Wilson

"True friendship is like sound health; the value of it is seldom known until it be lost."
~ Charles Caleb Colton

"A new friendship is like an unripened fruit - it may become either an orange or a lemon"
~ Emma Stacey

"Friendship with oneself is all-important because without it one cannot be friends with anyone else in the world."
~ Eleanor Roosevelt

Anonymous Quotes:

"Be careful of what you say, friendship can end in one minute because of a stupid word."

"Love is blind, but friendship closes its eyes."

Building a friendship is like planting a quote.

"No love, no friendship can cross the path of our destiny
without leaving some kind of mark on it forever."

"A friendship that stops existing, was actually never there."

"You will never have a perfect friendship,
but you must strive for one."

"Friendship doubles your joys, and divides your sorrows."

Friendship Day

Friendship Day


What is Friendship Day

Friendship is not simply a relation but it is the connection of two hearts of comparable thoughts and feelings. The historical past of friendship day commences when men began dwell as a society. Simply because of a social creature males adore to make close friends to additional this process of socialization.

A good friend is the man or woman in ones lifestyle to reveal all his feelings this kind of as his joy and his sorrows. There is nothing at all in the planet that could not reveal with a good friend. A good pal is the final refuge of each and every one. Thinking about the crucial and beneficial function of friends play in our lifestyle it was necessary to have a day committed to close friends & friendship.

The US Congress proclaimed initial Sunday of month August as the Countrywide Friendship Day. Because then celebration of Countrywide Friendship Day grew to become an yearly event and turn into well-known in the globe and almost all nations began to celebrate friendship day. Due to the fact no one particular is there in the whole world devoid of buddies, the day became 1 of the most well-known celebrations in the earth.

In Indian marathons the friendship between Arjuna & Krishna and Ram & Sugriv are extremely well-known. In bible there are so many tales that displays the value of friendship.

Friendship day in India: Like all other components of the world, In India also this day is rejoiced with excellent enthusiasm. But mostly the celebrations are celebrated in urban regions. There are several in the rural area they even do not have any thought about this day. Mostly youths and pupils are celebrate friendship day. Youngsters spend the total day with their buddies and exchange cards and presents and recollect the recollections.

Friendship day is progressively grow to be well-liked in all areas of India. Exchange of friendship wrist band is one of the notable component of celebrations. Typically the youngsters organize parties and devote total day together with great entertaining.

Friendship Day History

There is not much literature on Friendship Day history as we celebrate today. However, there are numerous folktales and several instance in mythological legends that shows that friends and friendship have been valued since the beginning of civilized world. As an intrinsically social creature, men love to make friends to further this process of socialization.

Friendship Day in India

Friendship day in India is very popular among the teenagers and is celebrated in a very large scale. It is a very noble gesture that is observed on first Sunday of the august month in the honor of friends and well wishers. Mostly celebrated in collages and offices in a very enthusiastic and festive mood, the friendship day brings joy and amusements in the youth of India.

In India, it is celebrated mostly in the urban sections of the society. People start preparing from the first week only to celebrate the friendship day with their friends and dear ones.

Friendship Day Band

Exchange of gifts and cards is very popular this day. But, as adapted from the western culture friendship day in India has also, adapted to the western gift styles. Friendship day band is the most popular exchange of love token on this day. This is usually handmade using colorful threads, ribbons and other crafts items like - beads, pendants and stones.

Many of the gift galleries have also, come with great ideas of exchanging this love token. Friendship day band is like expressing the strong bond between the two people. Friends are inseparable and would be there for each other for each other forever.

Friendship Day Celebrations

In India friendship day celebrations is more confined to the near and dear ones. In schools and colleges the youth exchanges cards, bands and gifts with each other. Your can see an atmosphere of exuberance and excitement among the teenagers and other youth sections of Indian society. Euphoria is set in the school campus. Everyone is in the festive mood and plans are being made for the celebrations.

With the changing scenario of communications - emails, e cards and cell phone texts have become more popular than, the traditional ways of expressing friendship. Friends send SMS to each other and the text messages are written with some notes and quotations. Here are few friendship day messages in India -

"If you open my heart, guess what u r gonna see? It's U. True friends are hard to find so I kept u."

"FRIENDSHIP isn't how U forget but how U forgive,
Not how U listen but how U Understand,
Not what U see but how U feel,
and not how U Let Go but how U hold on!!!
HAPPY FRIENDSHIP DAY!!"


"If u r a chocolate ur the sweetest, if u r a Teddy Bear u r the most huggable, If u r a Star u r the Brightest, and since u r my "FRIEND" u r the "BEST"!!!!!!!!!"

Youth make arrangements for picnics, visit to amusement parks and resultant bookings as; it becomes difficult to get a table in the restaurants. Even, the hotels and food joints offer great discounts on special cuisines prepared on this day. Coffee bars and pizza stations are the most favorite hangout places for the youth to enjoy friendship day party in India.

Movies and musical evenings are also, very popular among the youth. Discotheques and pubs are full on this day. The teenagers enjoy the friendship day bash with their close pals by hitting the discs and movie theatres. Friendship day in India is very much similar to that in the western nations as, the youth exchanges personalized gifts and flower with each other.

Day Dedicated to Friends

In tune with the spirit of the occasion, people dedicate Friendship Day
festival to their best friends. Most choose to celebrate the entire day
in the loving company of their dearest friends. Recollecting sweet
memories of the time spent together and catching up with their lives
over a cup of coffee is the idea of ideal Friendship Day celebration for
many.




Friends separated by geographical distances, call up their friends to
express love and warmth for each other and to wish a "Happy
Friendship Day". With more and more people getting hooked to the
net, many people also choose to chat with their friends with the help of
Internet. Sending SMS and Friendship Day e-cards is another popular way
of greetings friends.



Friendship Day Celebrations in Schools and Colleges

Friendship Day celebrations are particularly marked in schools and
colleges in India. Euphoria of the day sets in days before the festival
as everybody gets excited to wish their best friends in their own
special way. Children make Friendship Day Cards or other special gift to
thank their friends for their wonderful presence in their life. Exchange
of Friendship Bands is the other most prominent feature of Friendship
Day celebrations. Friends vie with each other as to who gets the most
stylish band or who gets the maximum number of bands.



In several colleges, special programs are also organized to mark the
occasion. Most of these programs and events intend to give youth an
opportunity to dance and sing with friends and have a good time.




Friendship Day Parties

Following their counterparts in the west, youth in India too mark
Friendship Day by participating in Friendship Day parties or organizing
bashes for their friends. Major crowd for Friendship Day can be seen in
discotheques and pubs where people dance with friends on fast pace music
and cherish the loving company of their pals. Such parties also give
youth a chance to make new friends and widen their friendship circle. At
present such bashes are more popular in metros and other big cities,
however, youth in small towns too are warming up to the idea of partying
on Friendship Day.



Commercialization of Friendship Day

Just as in US and several other countries, Friendship Day has been
commercialized to a great extent in India. Days before the festival,
gift marketers run an extensive campaign to lure the people to buy cards
and gifts for their friends. Restaurateurs too try to entice people by
offering special discounts or holding bashes. Several people criticize
such excessive campaigning. They feel commercialization has marred to
the idea behind observing Friendship Day and has turned it into a mere
formality. Some people however feel that advertising campaign has helped
to generate awareness about Friendship Day festival and the idea of
having a day dedicated to friends.




History of Friendship Day in US

Considering the valuable role friends play in our life it was deemed to fit to have a day dedicated to friends and friendship. The United States Congress, in 1935, proclaimed first Sunday of August as the National Friendship Day. Since then, celebration of National Friendship Day became an annual event. The noble idea of honoring the beautiful relationship of friendship caught on with the people and soon Friendship Day became a hugely popular festival.

Following the popularity and success of Friendship Day in US, several other countries adopted the tradition of dedicating a day to friends. Today, Friendship Day is enthusiastically celebrated by several countries across the world including India.

In 1997, the United Nations named Winnie - the Pooh as the world's Ambassador of Friendship.

Importance of Friendship in Bible

The Bible, the primary text of the western civilization, reflects upon friendship as the bond that forms the foundation to human faith, trust and companionship. Following verses from the bible aptly portray the importance of friends:

"Ask and it will be given to you; seek and you will find; knock and the door will be opened to you.”
Matthew 7:7

“Greater love hath no man than this that a man lay down his life for his friends.”
John 15:13-15

Besides, there are several tales from the Old Testament and the New Testament about the value of friendship and how true friendship is a treasure to unearth. A noticeable point is that, both the versions make a difference between the two broad meanings of friendship- one is a mere acquaintance, the other is a more affectionate relation.

In the Old Testament, Abraham is called the “friend of God” because of the intimacy of his relations. God speaks to Moses face to face “as a man…unto his friend” (Ex 33:11). The romantic friendship of Ruth and Naomi, the devotion of the subordinate Hushai for David, or the mutual relation between David and Jonathan - the Old Testament is replete with these interesting tales of friends and friendship.

In the New Testament, the relationship between Jesus and his disciples clearly depicts how human friendship can constantly grow. From being teacher and disciple, to lord and servant their relationship finally grew to an unparalleled friendship.

Importance of Friendship in Mahabharata

In the famous Hindu epic ‘Mahabharata’, Lord Krishna demonstrates the many colors of friendship - affection, romance, brotherhood, protection, guidance, intimacy and even teasing. Friendship is all about these and much more.

PHP htmlentities Function

PHP htmlentities Function

Whenever you allow your users to submit text to your website, you need to be careful that you don't leave any security holes open for malicious users to exploit. If you are ever going to allow user submitted text to be visible by the public you should consider using the htmlentities function to prevent them from running html code and scripts that may be harmful to your visitors.

PHP - Converting HTML into Entities

The htmlentities function takes a string and returns the same string with
HTML converted into HTML entities.
For example, the string "<script>" would be converted to "&lt;script&gt;".

By converting the < and > into entities, it prevents the browser from using it
as an HTML element and it prevents the code from running if you were to display some user's
input on your website.

This may seem a little complicated, but if you think of the way a browser works, in separate stages,
it becomes a little easier. Let's look at the way the function htmlentities changes the
data at three different levels: in PHP, in raw HTML and in the web browser. The sample
string is a bad script that will redirect visitors to the malicious user's own website.

PHP Code:

// An imaginary article submission from a bad user
//  it will redirect anyone to example.com if the code is run in a browser
$userInput = "I am going to hax0r your site, hahaha!
 <script type='text/javascript'>

 window.location = 'http://www.example.com/'
 </script>'";
 
//Lets make it safer before we use it
$userInputEntities = htmlentities($userInput);

//Now we can display it
echo $userInputEntities;

The HTML output of the above script would be as follows:

Safe Raw HTML Code:

I am going to hax0r your site, hahaha!
 &lt;script type='text/javascript'&gt;
 window.location = 'http://www.example.com/'
 &lt;/script&gt;'

If we had not used htmlentities to convert any HTML code into safe entities, this is
what the raw HTML code would be and it would have redirect a visitor to example.com.

Dangerous Raw HTML Code:

I am going to hax0r your site, hahaha!
 <script type='text/javascript'>
 window.location = 'http://www.example.com/'
 </script>'

Those two HTML code examples are what you would see if you were to view source on the web page.
However, if you were just viewing the output normally in your browser you would
see the following.

Safe Display:

I am going to hax0r your site, hahaha!
<script type='text/javascript'>
window.location = 'http://www.example.com/'
</script>'

Dangerous Display:

You'd see whatever spammer site that the malicious user had sent you to. Probably
some herbal supplement site or weight loss pills would be displayed.

When Would You Use htmlentities?

Anytime you allow users to submit content to your website, that other visitors can see, you should
consider removing the ability to let them use HTML. Although this will remove a lot of cool things that
your users can do, like making heavily customized content, it will prevent your site from
a lot of common attacks. With some custom coding you can just remove specific tags
from running, but that is beyond the scope of this lesson.

Just remember, that when allowing users to submit content to your site you are also
giving them access to your website. Be sure you take the proper precautions.

PHP - Magic Quotes

PHP - Magic Quotes

Prior to PHP 6 there was a feature called magic quotes that was created to help protect newbie programmers from writing bad form processing code. Magic quotes would automatically escape risky form data that might be used for SQL Injection with a backslash \. The characters escaped by PHP include: quote ', double quote ", backslash \ and NULL characters.

However, this newbie protection proved to cause more problems than it solved and is not
in PHP 6. If your PHP version is any version before 6 then you should use this lesson
to learn more about how magic quotes can affect you.

Magic Quotes - Are They Enabled?

First things first, you need to check to see if you have magic quotes enabled on you server.
The get_magic_quotes_gpc function will return a 0 (off) or a 1 (on). These boolean values
will fit nicely into an if statement where 1 is true and 0 is false.

PHP Code:

if(get_magic_quotes_gpc())
 echo "Magic quotes are enabled";
else
 echo "Magic quotes are disabled";

Display:


Magic quotes are enabled

If you received the message "Magic quotes are enabled" then you should definitely
continue reading this lesson, if not feel free to learn about it in case you
are developing for servers that might have quotes on or off.

Magic Quotes in Action

Now lets make a simple form processor to show how machines with magic quotes
enabled will escape those potentially risky characters. This form submits to itself, so
you only need to make one file, "magic-quotes.php" to test it out.

magic-quotes.php Code:

<?php
echo "Altered Text: ".$_POST['question'];
?>

<form method='post'>

Question: <input type='text' name='question'/><br />
<input type='submit'>

</form>

This simple form will display to you what magic quotes is doing. If you were to
enter and submit the string: Sandy said, "It's a beautiful day outside and I like to use \'s."
You would receive the following output.

Display:

Altered Text: Sandy said, \"It\'s a beautiful day outside and I like to use \\\'s.\"

Question:




Magic quotes did a number on that string, didn't it? Notice that
there is a backslash before all of those risky characters we talked about earlier.
After magic quotes:
  • A backslash \ becomes \\
  • A quote ' becomes \'
  • A double-quote " becomes \"

Now say that you wanted to remove the escaping that magic quotes puts in, you have two options:
disable magic quotes or strip the backslashes magic quotes adds.

Removing Backslashes - stripslashes()

Before you use PHP's backslash removal function stripslashes it's smart
to add some magic quote checking like our "Are They Enabled?" section above. This way
you won't accidentally be removing slashes that are legitimate in the future if
your PHP's magic quotes setting changes in the future.

magic-quotes.php Code:

<?php
echo "Removed Slashes: ";

// Remove those slashes
if(get_magic_quotes_gpc())
 echo stripslashes($_POST['question']);
else
 echo $_POST['question'];
 
?>

<form method='post'>
Question: <input type='text' name='question'/><br />
<input type='submit'>

</form>


Our new output for our string containing risky characters would now be:

Display:

Removed Slashes: Sandy said, "It's a beautiful day outside and I like to use \'s."
Question:

PHP - POST & GET

PHP - POST & GET

Recall from the PHP Forms Lesson where we used an HTML form and sent it to a PHP web page for processing. In that lesson we opted to use the the post method for submitting, but we could have also chosen the get method. This lesson will review both transferring methods.

POST - Review

In our PHP Forms Lesson we
used the post method. This is what the pertinent line of HTML code looked like:





HTML Code Excerpt:

<form action="process.php" method="post">
<select name="item">
...
<input name="quantity" type="text" />

This HTML code specifies that the form data will be submitted to the "process.php" web
page using the POST method. The way that PHP does this is to store all the "posted"
values into an associative array called "$_POST". Be sure to take notice the names
of the form data names, as they represent the keys in the "$_POST" associative array.

Now that you know about associative arrays,
the PHP code from "process.php" should make a litte more sense.


PHP Code Excerpt:

$quantity = $_POST['quantity'];
$item = $_POST['item'];
The form names are used as the keys in the associative array, so be
sure that you never have two input items in your HTML form that have the same name. If you do, then
you might see some problems arise.

PHP - GET

As we mentioned before, the alternative to the post method is get. If
we were to change our HTML form to the get method, it would look like this:



HTML Code Excerpt:

<form action="process.php" method="get">
<select name="item">
...
<input name="quantity" type="text" />

The get method is different in that it passes the variables along
to the "process.php" web page by appending them onto the end of the URL. The URL, after clicking submit,
would have this added on to the end of it:

"?item=##&quantity=##"

The question mark "?" tells the browser that the following items are variables. Now that we changed
the method of sending information on "order.html", we must change the "process.php" code
to use the "$_GET" associative array.



PHP Code Excerpt:

$quantity = $_GET['quantity'];
$item = $_GET['item'];

After changing the array name the script will function properly. Using
the get method displays the variable information to your visitor, so be sure
you are not sending password information or other sensitive items with the get method.
You would not want your visitors seeing something they are not supposed to!

Security Precautions

Whenever you are taking user input and using you need to be sure that the input is safe. If you are going to insert the data into a MySQL database, then you should be sure you have thought about preventing MySQL Injection. If you are going to make a user's input available to the public, then you should think about PHP htmlentities.

PHP - Do While Loop

PHP - Do While Loop

A "do while" loop is a slightly modified version of the while loop. If you recal from one of the previous lessons on While Loops the conditional statement is checked comes back true then the code within the while loop is executed. If the conditional statement is false then the code within the loop is not executed.

PHP - While Loop and Do While Loop Contrast

A simple example that illustrates the difference between these two loop types is
a conditional statement that is always false. First the while loop:



PHP Code:

$cookies = 0;
while($cookies > 1){
 echo "Mmmmm...I love cookies! *munch munch munch*";
} 

Display:





As you can see, this while loop's conditional statement failed (0 is not greater than 1), which means the code
within the while loop was not executed. Now, can you guess what will happen with
a do-while loop?

PHP Code:

$cookies = 0;
do {
 echo "Mmmmm...I love cookies! *munch munch munch*";
} while ($cookies > 1);

Display:

Mmmmm...I love cookies! *munch munch munch*

The code segment "Mmmm...I love cookies!" was executed even though the conditional
statement was false. This is because a do-while loop first do's and secondly checks the

while condition!

Chances are you will not need to use a do while loop in most of your PHP programming, but it
is good to know it's there!

PHP - For Loop

PHP - For Loop

The for loop is simply a while loop with a bit more code added to it. The common tasks that are covered by a for loop are:


  • Set a counter variable to some initial value.



  • Check to see if the conditional statement is true.



  • Execute the code within the loop.




  • Increment a counter at the end of each iteration through the loop.


  • The for loop allows you to define these steps in one easy line of code.
    It may seem to have a strange form, so pay close attention to the syntax used!

    For Loop Example

    Let us take the example from the while loop lesson and see how
    it could be done in a for loop. The basic structure of the for loop is as
    follows:


    Pseudo PHP Code:

    for ( initialize a counter; conditional statement; increment a counter){
     do this code;
    }
    

    Notice how all the steps of the loop are taken care of in the for loop
    statement. Each step is separated by a semicolon: initiliaze counter, conditional statement, and the
    counter increment. A semicolon is needed because these are separate expressions. However, notice
    that a semicolon is not needed after the "increment counter" expression.
    Here is the example of the brush prices done with a for loop .

    PHP Code:

    $brush_price = 5; 
    
    echo "<table border=\"1\" align=\"center\">";
    echo "<tr><th>Quantity</th>";
    echo "<th>Price</th></tr>";
    for ( $counter = 10; $counter <= 100; $counter += 10) {
     echo "<tr><td>";
     echo $counter;
     echo "</td><td>";
     echo $brush_price * $counter;
     echo "</td></tr>";
    }
    echo "</table>";
    
    

    Display:

    QuantityPrice
    1050
    20100
    30150
    40200
    50250
    60300
    70350
    80400
    90450
    100500

    It is important to note that both the for loop and while loop
    implementation of the price chart table are both OK at getting the job done. However,
    the for loop is somewhat more compact and would be preferable in this situation. In
    later lessons we will see where the while loop should be used instead of the for loop.

    PHP For Each Loop

    Imagine that you have an associative array that you want to iterate through. PHP provides an easy way to use every element of an array with the Foreach statement.

    In plain english this statement will do the following:
    • For each item in the specified array execute this code.
    While a For Loop and
    While Loop will continue
    until some condition fails, the For Each loop will continue until
    it has gone through every item in the array.

    PHP For Each: Example

    We have an associative array that stores the names of people in our
    company as the keys with the values being their age. We want
    to know how old everyone is at work so we use a Foreach loop to print
    out everyone's name and age.

    PHP Code:

    $employeeAges;
    $employeeAges["Lisa"] = "28";
    $employeeAges["Jack"] = "16";
    $employeeAges["Ryan"] = "35";
    $employeeAges["Rachel"] = "46";
    $employeeAges["Grace"] = "34";
    
    foreach( $employeeAges as $key => $value){
     echo "Name: $key, Age: $value <br />";
    }
    

    Display:

    Name: Lisa, Age: 28

    Name: Jack, Age: 16

    Name: Ryan, Age: 35


    Name: Rachel, Age: 46

    Name: Grace, Age: 34

    The syntax of the foreach statement is a little strange, so let's talk about it some.


    Foreach Syntax: $something as $key => $value

    This crazy statement roughly translates into: For each element of the
    $employeeAges associative array I want to refer to the key as $key and the value as $value.

    The operator "=>" represents the relationship between a key and value. You can imagine that
    the key points => to the value. In our example we named the key $key and the value $value.
    However, it might be easier to think of it as $name and $age. Below our example does this and notice how the output
    is identical because we only changed the variable names that refer to the keys and values.

    PHP Code:

    $employeeAges;
    $employeeAges["Lisa"] = "28";
    $employeeAges["Jack"] = "16";
    $employeeAges["Ryan"] = "35";
    $employeeAges["Rachel"] = "46";
    $employeeAges["Grace"] = "34";
    
    foreach( $employeeAges as $name => $age){
     echo "Name: $name, Age: $age <br />";
    }
    

    Display:

    Name: Lisa, Age: 28

    Name: Jack, Age: 16


    Name: Ryan, Age: 35

    Name: Rachel, Age: 46

    Name: Grace, Age: 34

    PHP - While Loop

    PHP - While Loop

    Repetitive tasks are always a burden to us. Deleting spam email, sealing 50 envelopes, and going to work are all examples of tasks that are repeated. The nice thing about programming is that you can avoid such repetitive tasks with a little bit of extra thinking. Most often these repetitive tasks are conquered in the loop.

    The idea of a loop is to do something over and over again until the task
    has been completed. Before we show a real example of when you might need one,
    let's go over the structure of the PHP while loop.


    Simple While Loop Example

    The function of the while loop is to do a task over and over as long
    as the specified conditional statement is true. This logical check is the same
    as the one that appears in a PHP if statement to determine if it is true or false.
    Here is the basic structure of a PHP while loop:



    Pseudo PHP Code:

    while ( conditional statement is true){
     //do this code;
    }
    
    This isn't valid PHP code, but it displays how the while loop is structured.
    Here is the break down of how a while loop functions when your script is executing:

    1. The conditional statement is checked. If it is true, then (2) occurs. If it is false, then (4) occurs.
    2. The code within the while loop is executed.
    3. The process starts again at (1). Effectively "looping" back.
    4. If the conditional statement is false, then the code within is not executed and there is no more looping. The code following
      the while loop is then executed like normal.

    A Real While Loop Example

    Imagine that you are running an art supply store. You would
    like to print out the price chart for number of brushes and total cost.
    You sell brushes at a flat rate, but would like to display how much
    different quantities would cost. This will save your customers from having to
    do the mental math themselves.
    You know that a while loop would be perfect for this repetitive and boring task.
    Here is how to go about doing it.

    Pseudo PHP Code:

    $brush_price = 5; 
    $counter = 10;
    
    echo "<table border=\"1\" align=\"center\">";
    echo "<tr><th>Quantity</th>";
    echo "<th>Price</th></tr>";
    while ( $counter <= 100 ) {
     echo "<tr><td>";
     echo $counter;
     echo "</td><td>";
     echo $brush_price * $counter;
     echo "</td></tr>";
     $counter = $counter + 10;
    }
    echo "</table>";
    
    

    Display:

    QuantityPrice
    1050
    20100
    30150
    40200
    50250
    60300
    70350
    80400
    90450
    100500

    Pretty neat, huh? The loop created a new table row and its respective entries
    for each quantity, until our counter variable grew past the size of 100. When it
    grew past 100 our conditional statement failed and the loop stopped being used. Let's review
    what is going on.
    1. We first made a $brush_price and $counter variable and
      set them equal to our desired values.
    2. The table was set up with the beginning table tag and the table headers.
    3. The while loop conditional statement was checked, and $counter (10) was indeed
      smaller or equal to 100.
    4. The code inside the while loop was executed, creating a new table row for the price
      of 10 brushes.
    5. We then added 10 to $counter to bring the value to 20.
    6. The loop started over again at step 3, until $counter grew larger than 100.
    7. After the loop had completed, we ended the table.

    You may have noticed that we placed slashes
    infront the quotations in the first echo statement. You have to place slashes
    before quotations if you do not want the quotation to act as the end of the echo statement.
    This is called escaping a character and it is discussed in our PHP Strings lesson.

    With proper use of loops you can complete large tasks
    with great ease.

    PHP Array

    PHP Array

    An array is a data structure that stores one or more values in a single value. For experienced programmers it is important to note that PHP's arrays are actually maps (each key is mapped to a value).

    PHP - A Numerically Indexed Array

    If this is your first time seeing an array, then you may not quite
    understand the concept of an array. Imagine that you own a business and
    you want to store the names of all your employees in a PHP variable. How
    would you go about this?
    It wouldn't make much sense to have to store each name
    in its own variable. Instead, it would be nice to store all the employee names inside
    of a single variable. This can be done, and we show you how below.


    PHP Code:

    $employee_array[0] = "Bob";
    $employee_array[1] = "Sally";
    $employee_array[2] = "Charlie";
    $employee_array[3] = "Clare";
    
    

    In the above example we made use of the key / value structure of an array. The keys
    were the numbers we specified in the array and the values were the names of the employees.
    Each key of an array represents a value that we can manipulate and reference. The
    general form for setting the key of an array equal to a value is:
    • $array[key] = value;

    If we wanted to reference the values that we stored into our array, the following
    PHP code would get the job done.

    Note: As you may have noticed from the above code example, an array's keys start from 0 and not 1. This is a very common problem for many new programmers who are used to counting from 1 and lead to "off by 1" errors. This is just something that will take experience before you are fully comfortable with it.

    PHP Code:

    echo "Two of my employees are "
    . $employee_array[0] . " & " . $employee_array[1]; 
    echo "<br />Two more employees of mine are " 
    . $employee_array[2] . " & " . $employee_array[3];
    
    


    Display:

    Two of my employees are Bob & Sally

    Two more employees of mine are Charlie & Clare

    PHP arrays are quite useful when used in conjunction with
    loops, which we will talk about in a later lesson. Above we showed
    an example of an array that made use of integers for the keys (a numerically indexed
    array). However, you can also specify a string as the key, which is referred to as an associative array.

    PHP - Associative Arrays

    In an associative array a key is associated with a value. If you wanted
    to store the salaries of your employees in an array, a numerically indexed array would
    not be the best choice. Instead, we could use the employees names as the keys in our
    associative array, and the value would be their respective salary.


    PHP Code:

    $salaries["Bob"] = 2000;
    $salaries["Sally"] = 4000;
    $salaries["Charlie"] = 600;
    $salaries["Clare"] = 0;
    
    echo "Bob is being paid - $" . $salaries["Bob"] . "<br />";
    echo "Sally is being paid - $" . $salaries["Sally"] . "<br />";
    echo "Charlie is being paid - $" . $salaries["Charlie"] . "<br />";
    echo "Clare is being paid - $" . $salaries["Clare"];
    
    

    Display:

    Bob is being paid - $2000

    Sally is being paid - $4000

    Charlie is being paid - $600

    Clare is being paid - $0

    Once again, the usefulness of arrays will become more apparent
    once you have knowledge of for and while loops.

    PHP - Functions

    PHP - Functions

    A function is just a name we give to a block of code that can be executed whenever we need it. This might not seem like that big of an idea, but believe me, when you understand and use functions you will be able to save a ton of time and write code that is much more readable!

    For example, you might have a company motto that you have to display at least once on every webpage. If you don't, then you get fired! Well, being the savvy PHP programmer you are, you think to yourself, "this sounds like a situation where I might need functions."


    Tip: Although functions are often thought of as an advanced topic for beginning programmers to learn, if you take it slow and stick with it, functions can be just minor speedbump in your programming career. So don't give up if you functions confuse you at first!

    Creating Your First PHP Function


    When you create a function, you first need to give it a name, like myCompanyMotto.
    It's with this function name that you will be able to call upon your function, so make it easy to type and understand.

    The actual syntax for creating a function is pretty self-explanatory, but you can be the judge of that.
    First, you must tell PHP that you want to create a function. You do this by typing the keyword function followed
    by your function name and some other stuff (which we'll talk about later).

    Here is how you would make a function called myCompanyMotto. Note: We still have
    to fill in the code for myCompanyMotto.


    PHP Code:

    <?php
    function myCompanyMotto(){
    }
    ?>
    

    Note: Your function name can start with a letter or underscore "_", but not a number!

    With a properly formatted function in place, we can now fill in the code that we want our
    function to execute. Do you see the curly braces in the above example "{ }"? These braces define
    where our function's code goes. The opening curly brace "{" tells php that the function's code is starting and a closing
    curly brace "}" tells PHP that our function is done!

    We want our function to print out the company motto each time it's called, so that sounds like it's a job for the echo command!


    PHP Code:

    <?php
    function myCompanyMotto(){
        echo "We deliver quantity, not quality!<br />";
    }
    ?>
    

    That's it! You have written your first PHP function from scratch! Notice that the code that appears within a function is just the same as any other PHP code.

    Using Your PHP Function

    Now that you have completed coding your PHP function, it's time to put it through a test run. Below
    is a simple PHP script. Let's do two things: add the function code to it and use the function twice.

    PHP Code:

    <?php
    echo "Welcome to Tizag.com <br />";
    echo "Well, thanks for stopping by! <br />";
    echo "and remember... <br />";
    ?>
    
    

    PHP Code with Function:

    <?php
    function myCompanyMotto(){
        echo "We deliver quantity, not quality!<br />";
    }
    echo "Welcome to Tizag.com <br />";
    myCompanyMotto();
    echo "Well, thanks for stopping by! <br />";
    echo "and remember... <br />";
    
    myCompanyMotto();
    ?>
    

    Display:

    Welcome to Tizag.com

    We deliver quantity, not quality!

    Well, thanks for stopping by!

    and remember...

    We deliver quantity, not quality!



    Although this was a simple example, it's important to understand that there
    is a lot going on and there are a lot of areas to make errors. When you are creating a function, follow
    these simple guidelines:

    • Always start your function with the keyword function
    • Remember that your function's code must be between the "{" and the "}"
    • When you are using your function, be sure you spell the function name correctly
    • Don't give up!

    PHP Functions - Parameters

    Another useful thing about functions is that you can send them information that
    the function can then use. Our first function myCompanyMotto isn't all that
    useful because all it does, and ever will do, is print out a single, unchanging string.

    However, if we were to use parameters, then we would be able to add some extra functionality!
    A parameter appears with the parentheses "( )" and looks just like a normal PHP variable.
    Let's create a new function that creates a custom greeting based off of a person's name.

    Our parameter will be the person's name and our function will concatenate this
    name onto a greeting string. Here's what the code would look like.

    PHP Code with Function:

    <?php
    function myGreeting($firstName){
        echo "Hello there ". $firstName . "!<br />";
    }
    ?>
    
    

    When we use our myGreeting function we have to send it a string containing someone's name, otherwise
    it will break. When you add parameters, you also add more responsibility to you, the programmer!
    Let's call our new function a few times with some common first names.

    PHP Code:

    <?php
    function myGreeting($firstName){
        echo "Hello there ". $firstName . "!<br />";
    }
    myGreeting("Jack");
    myGreeting("Ahmed");
    myGreeting("Julie");
    myGreeting("Charles");
    ?>
    

    Display:


    Hello there Jack!

    Hello there Ahmed!

    Hello there Julie!

    Hello there Charles!

    It is also possible to have multiple parameters in a function. To separate multiple parameters
    PHP uses a comma ",". Let's modify our function to also include last names.

    PHP Code:

    <?php
    function myGreeting($firstName, $lastName){
        echo "Hello there ". $firstName ." ". $lastName ."!<br />";
    }
    myGreeting("Jack", "Black");
    myGreeting("Ahmed", "Zewail");
    myGreeting("Julie", "Roberts");
    myGreeting("Charles", "Schwab");
    ?>
    
    

    Display:

    Hello there Jack Black!

    Hello there Ahmed Zewail!

    Hello there Julie Roberts!

    Hello there Charles Schwab!

    PHP Functions - Returning Values

    Besides being able to pass functions information, you can also have them return a value.
    However, a function can only return one thing, although that thing can be any integer, float, array, string, etc. that you choose!

    How does it return a value though? Well, when the function is used and finishes executing, it sort of changes from being a function name into being a value. To capture this value you can set a variable equal to the function. Something like:


    • $myVar = somefunction();

    Let's demonstrate this returning of a value by using a simple function that returns the sum of two integers.

    PHP Code:

    <?php
    function mySum($numX, $numY){
        $total = $numX + $numY;
        return $total; 
    }
    $myNumber = 0;
    
    echo "Before the function, myNumber = ". $myNumber ."<br />";
    $myNumber = mySum(3, 4); // Store the result of mySum in $myNumber
    echo "After the function, myNumber = " . $myNumber ."<br />";
    ?>
    

    Display:

    Before the function, myNumber = 0

    After the function, myNumber = 7

    When we first print out the value of $myNumber it is still set to the original value of 0.
    However, when we set $myNumber equal to the function mySum, $myNumber
    is set equal to mySum's result. In this case, the result was 3 + 4 = 7, which was successfully
    stored into $myNumber and displayed in the second echo statement!

    PHP Functions - Practice Makes Perfect

    If you are new to programming, then this lesson might or might not seem like overkill. If you
    are having a hard time understanding lessons, the best piece of advice would be to do your best
    the first time, then be sure to come back tomorrow and next week and see if it makes
    anymore sense. Chances are, after going through this tutorial more than once, with
    breaks in between, this topic will be mastered.

    PHP Switch Statement

    PHP Switch Statement

    In the previous lessons we covered the various elements that make up an If Statement in PHP. However, there are times when an if statement is not the most efficient way to check for certain conditions.

    For example we might have a variable that stores travel destinations and you want
    to pack according to this destination variable. In this example you might have
    20 different locations that you would have to check with a nasty long block
    of If/ElseIf/ElseIf/ElseIf/... statements. This doesn't sound like much fun to code,
    let's see if we can do something different.

    PHP Switch Statement: Speedy Checking

    With the use of the switch statement you can check for all these
    conditions at once, and the great thing is that it is actually more efficient
    programming to do this. A true win-win situation!

    The way the Switch statement works is it takes a single variable as input
    and then checks it against all the different cases you set up for that
    switch statement. Instead of having to check that variable one at a time,
    as it goes through a bunch of If Statements, the Switch statement only has to check
    one time.



    PHP Switch Statement Example


    In our example the single variable will be $destination

    and the cases will be: Las Vegas, Amsterdam, Egypt, Tokyo, and the Caribbean Islands.

    PHP Code:

    $destination = "Tokyo";
    echo "Traveling to $destination<br />";
    switch ($destination){
     case "Las Vegas":
      echo "Bring an extra $500";
      break;
     case "Amsterdam":
      echo "Bring an open mind";
      break; 
     case "Egypt":
      echo "Bring 15 bottles of SPF 50 Sunscreen";
      break; 
     case "Tokyo":
      echo "Bring lots of money";
      break;
     case "Caribbean Islands":
      echo "Bring a swimsuit";
      break; 
    }
    

    Display:

    Traveling to Tokyo

    Bring lots of money
    The value of $destination was Tokyo, so when PHP performed the switch

    operating on $destination in immediately did a search for a case with the
    value of "Tokyo". It found it and proceeded to execute the code that existed
    within that segment.

    You might have noticed how each case contains a break; at the end of its code area. This
    break prevents the other cases from being executed. If the above example did not
    have any break statements then all the cases that follow Tokyo would have been executed as well.
    Use this knowledge to enhance the power of your switch statements!
    The form of the switch statement is rather unique, so spend some time reviewing it
    before moving on. Note: Beginning programmers should always include the break; to
    avoid any unnecessary confusion.

    PHP Switch Statement: Default Case

    You may have noticed the lack of a place for code when the
    variable doesn't match our condition. The if statement has the else clause and
    the switch statement has the default case.

    It's usually a good idea to always include the default case in all your switch
    statements. Below is a variation of our example that will result in none of the cases
    being used causing our switch statement to fall back and use the default case. Note: the word
    case does not appear before the word default, as default is a special keyword!


    PHP Code:

    $destination = "New York";
    echo "Traveling to $destination<br />";
    switch ($destination){
     case "Las Vegas":
      echo "Bring an extra $500";
      break;
     case "Amsterdam":
      echo "Bring an open mind";
      break;
     case "Egypt":
      echo "Bring 15 bottles of SPF 50 Sunscreen";
      break; 
     case "Tokyo":
      echo "Bring lots of money";
      break; 
     case "Caribbean Islands":
      echo "Bring a swimsuit";
      break;  
     default:
      echo "Bring lots of underwear!";
      break;
    
    }
    

    Display:

    Traveling to New York

    Bring lots of underwear!

    Using PHP With HTML Forms

    It is time to apply the knowledge you have obtained thus far and put it to real use. A very common application of PHP is to have an HTML form gather information from a website's visitor and then use PHP to do process that information. In this lesson we will simulate a small business's website that is implementing a very simple order form.

    Imagine we are an art supply store that
    sells brushes, paint, and erasers. To gather order information
    from our prospective customers we will have to make a page with an HTML form
    to gather the customer's order.

    Note: This is an oversimplified example to educate you how to
    use PHP to process HTML form information. This example
    is not intended nor advised to be used on a real business website.

    Creating the HTML Form

    If you need a refresher on how to properly make an HTML form,
    check out the HTML Form
    Lesson
    before continuing on.

    We first create an HTML form that will let our customer choose
    what they would like to purchase. This file should be saved
    as "order.html"
    .

    order.html Code:

    <html><body>
    <h4>Tizag Art Supply Order Form</h4>
    <form> 
    <select> 
    <option>Paint</option>
    
    <option>Brushes</option>
    <option>Erasers</option>
    </select>
    Quantity: <input type="text" /> 
    <input type="submit" />
    </form>
    
    </body></html>
    

    Display:

    Tizag Art Supply Order Form


    Quantity:


    Remember to review HTML Forms
    if you do not understand any of the above HTML code. Next we must alter
    our HTML form to specify the PHP page we wish to send this information to. Also,
    we set the method to "post".

    order.html Code:

    <html><body>
    
    <h4>Tizag Art Supply Order Form</h4>
    <form action="process.php" method="post"> 
    <select name="item"> 
    <option>Paint</option>
    <option>Brushes</option>
    
    <option>Erasers</option>
    </select>
    Quantity: <input name="quantity" type="text" /> 
    <input type="submit" />
    </form>
    </body></html>
    
    

    Now that our "order.html" is complete, let us continue on and
    create the "process.php" file which will process the HTML form information.

    PHP Form Processor

    We want to get the "item" and "quantity" inputs that we have specified
    in our HTML form. Using an associative array (this term is explained in the array lesson),
    we can get this information from the $_POST associative array.

    The proper way to get this information would be to create two new variables, $item
    and $quantity and set them equal to the values that have been "posted". The name
    of this file is "process.php".

    process.php Code:

    <html><body>
    <?php
    $quantity = $_POST['quantity'];
    $item = $_POST['item'];
    
    echo "You ordered ". $quantity . " " . $item . ".<br />";
    echo "Thank you for ordering from Tizag Art Supplies!";
    
    ?>
    </body></html>
    

    As you probably noticed, the name in $_POST['name'] corresponds
    to the name that we specified in our HTML form.

    Now try uploading the "order.html" and "process.php" files to a PHP
    enabled server and test them out. If someone selected the item brushes
    and specified a quantity of 6, then the following
    would be displayed on "process.php":

    process.php Code:

    You ordered 6 brushes.
    Thank you for ordering from Tizag Art Supplies!
    

    PHP & HTML Form Review

    A lot of things were going on in this example. Let us step through
    it to be sure you understand what was going on.

    1. We first created an HTML form "order.html" that had two input fields
      specified, "item" and "quantity".
    2. We added two attributes to the form tag to point to "process.php" and
      set the method to "post".
    3. We had "process.php" get the information that was posted
      by setting new variables equal to the values in the $_POST associative array.
    4. We used the PHP echo function to output the customers order.

    Remember, this lesson is only to teach you how to use PHP to get information
    from HTML forms. The example on this page should not be used for a real business.

    The If Statement in PHP

    The If Statement

    The PHP if statement is very similar to other programming languages use of the if statement, but for those who are not familiar with it, picture the following:

    Think about the decisions you make before you go to sleep. If you have
    something to do the next day, say go to work, school, or an appointment, then

    you will set your alarm clock to wake you up. Otherwise, you will sleep in as
    long as you like!
    This simple kind of if/then statement is very common in every day life and
    also appears in programming quite often. Whenever you want to make a decision
    given that something is true (you have something to do tomorrow) and be sure that you
    take the appropriate action, you are using an if/then relationship.

    The PHP If Statement

    The if statement is necessary for most programming, thus it is important in PHP. Imagine that on January
    1st you want to print out "Happy New Year!" at the top of your personal web page. With the use of PHP if statements you could have this process automated,
    months in advance, occuring every year on January 1st.
    This idea of planning for future
    events is something you would never have had the opportunity of doing if you
    had just stuck with HTML.

    If Statement Example

    The "Happy New Year" example would be a little difficult for you
    to do right now, so let us instead start off with the basics of the if statement.
    The PHP if statement tests to see if a value is true, and if it is a segment of
    code will be executed. See the example below for the form of a PHP if statement.

    PHP Code:

    $my_name = "someguy";
    
    if ( $my_name == "someguy" ) {
     echo "Your name is someguy!<br />";
    }
    echo "Welcome to my homepage!";
    

    Display:

    Your name is someguy!

    Welcome to my homepage!

    Did you get that we were comparing the variable $my_name with "someguy" to see if they
    were equal? In PHP you use the double equal sign (==) to compare values.
    Additionally, notice that because the if statement turned out to be true, the code segment
    was executed, printing out "Your name is someguy!". Let's go a bit more in-depth into this example
    to iron out the details.
    • We first set the variable $my_name equal to "someguy".
    • We next used a PHP if statement to check if the value contained in the
      variable $my_name was equal to "someguy"
    • The comparison between $my_name and "someguy" was done with a double equal
      sign "==", not a single equals"="! A single equals is for assigning a value
      to a variable, while a double equals is for checking if things are equal.
    • Translated into english the PHP statement ( $my_name == "someguy" ) is ( $my_name
      is equal to "someguy" ).
    • $my_name is indeed equal to "someguy" so the echo statement is executed.

    A False If Statement

    Let us now see what happens when a PHP if statement is not true, in
    other words, false. Say that we changed the above example to:

    PHP Code:

    $my_name = "anotherguy";
    
    if ( $my_name == "someguy" ) {
     echo "Your name is someguy!<br />";
    }
    echo "Welcome to my homepage!";
    

    Display:

    Welcome to my homepage!

    Here the variable contained the value "anotherguy", which is not equal to "someguy".
    The if statement evaluated to false, so the code segment of the if statement was not
    executed. When used properly, the if statement is a powerful tool to have in your
    programming arsenal!

    If/Else Conditional Statment

    Has someone ever told you, "if you work hard, then you will succeed"? And what happens if you do not work hard? Well, you fail! This is an example of an if/else conditional statement.


  • If you work hard then you will succeed.


  • Else, if you do not work hard, then you will fail.

  • How does this translate into something useful for PHP developers?
    Well consider this:

    Someone comes to your website and you want to ask
    this visitor her name if it is her first time coming to your site. With an if statement
    this is easy. Simply have a conditional statement to check, "are
    you visiting for the first time". If the condition is true, then take them to
    the "Insert Your Name" page, else let her view the website as normal because you have already asked her for her name
    in the past.


    If/Else an Example

    Using these conditional statements can add a new layers of "cool" to your
    website. Here's the basic form of an if/else statement in PHP.

    PHP Code:

    $number_three = 3;
    
    if ( $number_three == 3 ) {
     echo "The if statement evaluated to true";
    } else {
     echo "The if statement evaluated to false";
    }
    

    Display:

    The if statement evaluated to true
    This is a lot to digest in one sitting, so let us step through the
    code, line by line.

    • We first made a PHP variable called $number_three and set it equal to 3.
    • In this example we compared a variable to
      an integer value. To do such a comparison we use "==", which in English means "Is Equal To".
    • $number_three is indeed Equal To 3 and so this statement will evaluate to true.
    • All code that is contained between the opening curly brace "{" that follows the if
      statement and the closing curly brace "}" will be executed when the if statement is true.
    • The code contained within the else segment will not used.

    Execute Else Code with False

    On the other hand, if the if statement was false, then the code contained in the else segment would have been
    executed. Note that the code within the if and else cannot both be executed, as
    the if statement cannot evaluate to both true and false at one time! Here is what would happen
    if we changed to $number_three to anything besides the number 3.


    PHP Code:

    $number_three = 421;
    
    if ( $number_three == 3 ) {
     echo "The if statement evaluated to true";
    } else {
     echo "The if statement evaluated to false";
    }
    
    

    Display:

    The if statement evaluated to false
    The variable was set to 421, which is not equal to 3 and the if statement was false. As you can see,
    the code segment contained within the else was used in this case.

    PHP - Elseif

    An if/else statement is great if you only need to check for one condition. However, what would you do if you wanted to check if your $employee variable was the company owner Bob, the Vice President Ms. Tanner, or a regular employee? To check for these different conditions you would need the elseif statement.

    PHP - Elseif What is it?

    An if statement is made up of the keyword "if" and a conditional statement (i.e. $name == "Ted").
    Just like an if statement, an elseif statement also contains a conditional statement, but it must be preceded
    by an if statement. You cannot have an elseif statement without first having an if statement.


    When PHP evaluates your If...elseif...else statement it will first see if the If statement is true. If that
    tests comes out false it will then check the first elseif statement. If that is false it will either check the next
    elseif statement, or if there are no more elseif statements, it will evaluate the else segment, if one exists (I don't
    think I've ever used the word "if" so much in my entire life!). Let's take a look at a real world example.

    PHP - Using Elseif with If...Else

    Let's start out with the base case. Imagine we have a simpler version of the problem described above.
    We simply want
    to find out if the employee is the Vice President Ms. Tanner. We only need an if else statement for
    this part of the example.

    PHP Code:

    $employee = "Bob";
    if($employee == "Ms. Tanner"){
     echo "Hello Ma'am";
    } else {
     echo "Morning";
    }
    
    Now, if we wanted to also check to see if the big boss Bob was the employee we need
    to insert an elseif clause.

    PHP Code:

    $employee = "Bob";
    if($employee == "Ms. Tanner"){
     echo "Hello Ma'am";
    } elseif($employee == "Bob"){
     echo "Good Morning Sir!";
    }else {
     echo "Morning";
    }
    

    Display:

    Good Morning Sir!

    PHP first checked to see if $employee was equal to "Ms. Tanner", which evaluated to
    false. Next, PHP checked the first elseif statement. $employee did in
    fact equal "Bob" so the phrase "Good Morning Sir!" was printed out. If we wanted
    to check for more employee names we could insert more elseif statements!

    Remember that an elseif statement cannot be used unless it is preceded
    by an if statement!

    PHP - Operators

    PHP - Operators

    In all programming languages, operators are used to manipulate or perform operations on variables and values. You have already seen the string concatenation operator "." in the Echo Lesson and the assignment operator "=" in pretty much every PHP example so far.

    There are many operators used in PHP, so we have separated them into
    the following categories to make it easier to learn them all.
    • Assignment Operators
    • Arithmetic Operators
    • Comparison Operators
    • String Operators
    • Combination Arithmetic & Assignment Operators


    Assignment Operators

    Assignment operators are used to set a variable equal to a value or set
    a variable to another variable's value. Such an assignment of value is done with
    the "=", or equal character. Example:


    • $my_var = 4;
    • $another_var = $my_var;
    Now both $my_var and $another_var contain the value 4. Assignments can also be used in conjunction with arithmetic operators.

    Arithmetic Operators

    OperatorEnglishExample
    + Addition 2 + 4
    - Subtraction 6 - 2
    * Multiplication 5 * 3
    / Division 15 / 3
    % Modulus 43 % 10


    PHP Code:

    $addition = 2 + 4; 
    $subtraction = 6 - 2; 
    $multiplication = 5 * 3; 
    $division = 15 / 3; 
    $modulus = 5 % 2; 
    echo "Perform addition: 2 + 4 = ".$addition."<br />"; 
    echo "Perform subtraction: 6 - 2 = ".$subtraction."<br />"; 
    echo "Perform multiplication:  5 * 3 = ".$multiplication."<br />"; 
    echo "Perform division: 15 / 3 = ".$division."<br />"; 
    echo "Perform modulus: 5 % 2 = " . $modulus 
     . ". Modulus is the remainder after the division operation has been performed.  
     In this case it was 5 / 2, which has a remainder of 1.";
    

    Display:

    Perform addition: 2 + 4 = 6

    Perform subtraction: 6 - 2 = 4


    Perform multiplication: 5 * 3 = 15

    Perform division: 15 / 3 = 5

    Perform modulus: 5 % 2 = 1. Modulus is the remainder after the division operation has been performed.
    In this case it was 5 / 2, which has a remainder of 1.

    Comparison Operators

    Comparisons are used to check the relationship between variables and/or
    values. If you would like to see a simple example of a comparison operator in action, check out our
    If Statement Lesson. Comparison
    operators are used inside conditional statements and evaluate to either true
    or false. Here are the most important comparison operators of PHP.



    Assume: $x = 4 and $y = 5;

    OperatorEnglish Example Result
    == Equal To $x == $y false
    != Not Equal To $x != $y true
    < Less Than $x < $y true
    > Greater Than $x > $y false
    <= Less Than or Equal To $x <= $y true
    >= Greater Than or Equal To $x >= $y false



    String Operators

    As we have already seen in the Echo
    Lesson
    , the period "." is used to add two strings together, or more technically,
    the period is the concatenation operator for strings.



    PHP Code:

    $a_string = "Hello";
    $another_string = " Billy";
    $new_string = $a_string . $another_string;
    echo $new_string . "!";
    

    Display:

    Hello Billy!


    Combination Arithmetic & Assignment Operators

    In programming it is a very common task to have to increment a variable by some fixed amount. The
    most common example of this is a counter. Say you want to increment a counter by 1, you would
    have:

    • $counter = $counter + 1;
    However, there is a shorthand for doing this.
    • $counter += 1;
    This combination assignment/arithmetic operator would accomplish the same task. The downside to this
    combination operator is that it reduces code readability to those programmers who are not used to such
    an operator. Here are some examples of other common
    shorthand operators. In general, "+=" and "-=" are the most widely used combination operators.

    OperatorEnglish Example Equivalent Operation
    +=Plus Equals $x += 2; $x = $x + 2;
    -=Minus Equals $x -= 4; $x = $x - 4;
    *=Multiply Equals $x *= 3; $x = $x * 3;
    /=Divide Equals $x /= 2; $x = $x / 2;
    %=Modulo Equals $x %= 5; $x = $x % 5;
    .=Concatenate Equals $my_str.="hello"; $my_str = $my_str . "hello";

    Pre/Post-Increment & Pre/Post-Decrement

    This may seem a bit absurd, but there is even a shorter shorthand for the common
    task of adding 1 or subtracting 1 from a variable. To add one to a variable or "increment"
    use the "++" operator:
    • $x++; Which is equivalent to $x += 1; or $x = $x + 1;
    To subtract 1 from a variable, or "decrement" use the "--" operator:

    • $x--; Which is equivalent to $x -= 1; or $x = $x - 1;
    In addition to this "shorterhand" technique, you can specify whether you
    want to increment before the line of code is being executed or after the
    line has executed. Our PHP code below will display the difference.


    PHP Code:

    $x = 4;
    echo "The value of x with post-plusplus = " . $x++;
    echo "<br /> The value of x after the post-plusplus is " . $x;
    $x = 4;
    echo "<br />The value of x with with pre-plusplus = " . ++$x;
    echo "<br /> The value of x after the pre-plusplus is " . $x;
    

    Display:

    The value of x with post-plusplus = 4

    The value of x after the post-plusplus is = 5


    The value of x with with pre-plusplus = 5

    The value of x after the pre-plusplus is = 5
    As you can see the value of $x++ is not reflected in the echoed text because
    the variable is not incremented until after the line of code is executed. However,
    with the pre-increment "++$x" the variable does reflect the addition immediately.

    Using Comments in PHP

    Comments in PHP are similar to comments that are used in HTML. The PHP comment syntax always begins with a special character sequence and all text that appears between the start of the comment and the end will be ignored.

    In HTML a comment's main purpose is to serve as a note to you, the web developer or to others who may view your website's source code. However, PHP's comments are different in that they will not be displayed to your visitors. The only way to view PHP comments is to open the PHP file for editing. This makes PHP comments only useful to PHP programmers.

    In case you forgot what an HTML comment looked like, see our example below.

    HTML Code:

    <!-- This is an HTML Comment -->
    
    

    PHP Comment Syntax: Single Line Comment

    While there is only one type of comment in HTML, PHP has two types. The first type we will discuss is the single line comment. The single line comment tells the interpreter to ignore everything that occurs on that line to the right of the comment. To do a single line comment type "//" or "#" and all text to the right will be ignored by PHP interpreter.

    PHP Code:

    <?php
    echo "Hello World!"; // This will print out Hello World!
    echo "<br />Psst...You can't see my PHP comments!"; // echo "nothing";
    // echo "My name is Humperdinkle!";
    # echo "I don't do anything either";
    ?>
    

    Display:

    Hello World!


    Psst...You can't see my PHP comments!
    Notice that a couple of our echo statements were not evaluated because we
    commented them out with the single line comment.
    This type of line commenting is often used for quick notes about
    complex and confusing code or to temporarily remove a line of PHP code.


    PHP Comment Syntax: Multiple Line Comment

    Similiar to the HTML comment, the multi-line PHP comment
    can be used to comment out large blocks of code or writing multiple
    line comments. The multiple line PHP comment begins with " /* " and ends
    with " */ ".


    PHP Code:

    <?php
    /* This Echo statement will print out my message to the
    the place in which I reside on.  In other words, the World. */
    echo "Hello World!"; 
    /* echo "My name is Humperdinkle!";
    echo "No way! My name is Uber PHP Programmer!";
    */
    ?>
    

    Display:

    Hello World!

    Good Commenting Practices

    One of the best commenting practices that I can recommend to
    new PHP programmers is....USE THEM!! So many people write complex
    PHP code and are either too lazy to write good comments or believe
    the commenting is not needed. However, do you really believe that you
    will remember exactly what you were thinking when looking at this code
    a year or more down the road?
    Let the comments permeate your code and you will be a happier PHPer
    in the future. Use single line comments for quick notes about a tricky
    part in your code and use multiple line comments when you need to describe
    something in greater depth than a simple note.

    PHP Include

    Without understanding much about the details of PHP, you can save yourself a great deal of time with the use of the PHP include command. include takes a file name and simply inserts that file's contents into the script that issued the include command.

    Why is this a cool thing? Well, first of all, this means that you can type up a common header or menu file that you want all your web pages to include. When you add a new page to your site, instead of having to update the links on several web pages, you can simply change the Menu file.

    An Include Example

    Say we wanted to create a common menu file that all our pages
    will use. A common practice for naming files that are to be included is to use the ".php" extension. Since we want to create a common menu
    let's save it as "menu.php".

    menu.php Code:

    <html>
    <body>
    <a href="http://www.example.com/index.php">Home</a> - 
    <a href="http://www.example.com/about.php">About Us</a> - 
    <a href="http://www.example.com/links.php">Links</a> - 
    
    <a href="http://www.example.com/contact.php">Contact Us</a> <br />
    

    Save the above file as "menu.php". Now create a new file, "index.php" in the same directory as
    "menu.php". Here we will take advantage of the include command to add our common menu.

    index.php Code:

    <?php include("menu.php"); ?>
    
    <p>This is my home page that uses a common menu to save me time when I add
    new pages to my website!</p>
    </body>
    </html>
    

    Display:

    Home -
    About Us -

    Links -
    Contact Us
    This is my home page that uses a common menu to save me time when I add new pages to my website!
    And we would do the same thing for "about.php", "links.php", and "contact.php". Just think
    how terrible it would be if you had 15 or more pages with a common menu and you decided to add
    another web page to that site. You would have to go in and manually edit every single file to add this
    new page, but with include files you simply have to change "menu.php" and all your problems are solved.
    Avoid such troublesome occasions with a simple include file.

    What do Visitors See?

    If we were to use the include command to insert a menu on each of our web pages, what
    would the visitor see if they viewed the source of "index.php"? Well, because the include command
    is pretty much the same as copying and pasting, the visitors would see:

    View Source of index.php to a Visitor:

    <html>
    
    <body>
    <a href="index.php">Home</a> - 
    <a href="about.php">About Us</a> - 
    <a href="links.php">Links</a> - 
    
    <a href="contact.php">Contact Us</a> <br />
    <p>This is my home page that uses a common menu to save me time when I add
    new pages to my website!</p>
    </body>
    </html>
    

    The visitor would actually see all the HTML code as one long line of HTML code, because
    we have not inserted any new line characters. We did some formatting above to make it easier to read. We will be discussing new line characters later.

    Include Recap

    The include command simply takes all the text that exists in the specified file and copies
    it into the file that uses the include command. Include is quite useful when you want to include the same PHP, HTML, or text segment on multiple pages of a website. The include command is used widely by PHP web developers. Like PHP Echo, include is not a function, but a language construct.

    The next lesson will talk about a slight variation of the include command: require. It is often best to use the require command instead of the include command in your PHP Code. Read the next lesson to find out why!

    PHP Require

    Just like the previous lesson, the require command is used to include a file into your PHP code. However there is one huge difference between the two commands, though it might not seem that big of a deal.

    Require vs Include

    When you include a file with the include command and PHP cannot
    find it you will see an error message like the following:

    PHP Code:

    <?php
    include("noFileExistsHere.php");
    echo "Hello World!";
    ?>
    
    

    Display:

    Warning: main(noFileExistsHere.php): failed to open stream: No such file or directory in /home/websiteName/FolderName/tizagScript.php on line 2
    Warning: main(): Failed opening 'noFileExistsHere.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/websiteName/FolderName/tizagScript.php on line 2



    Hello World!

    Notice that our echo statement is still executed, this is because a Warning does not prevent our PHP script from running.
    On the other hand, if we did the same example but used the require statement we would get something like the following example.

    PHP Code:

    <?php
    require("noFileExistsHere.php");
    echo "Hello World!";
    ?>
    

    Display:

    Warning: main(noFileExistsHere.php): failed to open stream: No such file or directory in /home/websiteName/FolderName/tizagScript.php on line 2


    Fatal error: main(): Failed opening required 'noFileExistsHere.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/websiteName/FolderName/tizagScript.php on line 2

    The echo statement was not executed because our script execution died after the require command returned a fatal error! We recommend that you use require instead of include because your scripts should not be executing if necessary files are missing or misnamed.

    VMware Cloud Learning Video's

    Here is a nice summary list of all VMworld US 2018 Breakout session with the respective video playback & download URLs. Enjoy! Bra...