Posts marked with "echo" in tags

Define Array as Value of Constants in PHP

Constants are something that is needed for every computer languages. In PHP, too you can set constants. But you can only set string values which is a pity, because if you want to set arrays for making it easy for obtaining multiple values, you can’t do it. In this case, we explore the unimaginable possibilities of programming languages. As like any other language, PHP too has a secret weapon to accomplish this task.... [READ MORE]

Split Name in PHP and Javascript

If you have a user with a long name and want to short it because it won’t fit into the element that contains the name, you can either do it on the server or the client. In this post I am going to tell you how to accomplish this with PHP and JavaScript. Suppose We have a user named Paul Steve Panakkal (my cousin). To separate the first name, middle name and last name you can do the following in PHP :... [READ MORE]

How to redirect users to a page in PHP

If you want to redirect users to a specific page or url like when user is not logged in or something in PHP then you can accomplish this with header function or by Javascript printed by echo function. The following example will redirect user to Or you can use the normal Javascript : What’s the difference ? header function is called in server itself not when the page reaches the browser.... [READ MORE]

The best age calculation code in PHP

Age calculation is a tricky calculation especially in Programming Languages. I’m going to tell you a simple way to find out age in PHP. This is a simple function that will calculate age if it is given a birthday date in the format date/month/year. For example : 20/01/2000 or 04/12/1990 Here is the function : function age($birthday){  list($day,$month,$year) = explode("/",$birthday);  $year_diff  = date("Y") – $year;  $month_diff = date("m") – $month;  $day_diff   = date("... [READ MORE]



Mastodon  Twitter

GitHub GitLab


Demos  Lab


This blog was once on WordPress. Now a static site. See source code on