Constants in PHP – PHP WEBSITE DEVELOPMENT

In this video

Today we are going to learn about constants in PHP. In our last lecture we learned about string functions in PHP. If you haven’t watched it yet then here is the link of tutorial http://tutorialhive.net/2018/09/08/5-string-functions-in-php-php-website-development/. Today’s tutorial is about constants in PHP.

Constants in PHP

In this tutorial we will learn about constants in PHP and how to declare constants in PHP. First step is to run wamp server. Run wamp and after that go into drive where you installed wamp server. Open folder Wamp after that open folder www. Now create a new folder in ‘www‘ you can give any name to your folder, I am naming it tutorialhive. In folder create a file with name index.php. In your editor open your php file.

Constant

Constant is a value which remain same during your program or script.

Constant Declaration method

define(name, value);

<?php

define(“AGE”, 22);

echo AGE;

?>

Output: 22

Mostly developers prefer to write constants in PHP in Capital, so it is easy to find them.

Third parameter of define function

Define function has total three parameters. First is name then value and third one is for case sensitive. By default it is false which means it is case insensitive so whenever you have to call constant call it as it is. If it is true then does not need to worry about caps or small e.g. you can write’ echo AGE or age’.

Constants in PHP tutorial end here. In next tutorial we will learn about IF ELSE  in php. If you have any queries you can ask us on our Facebook page link is given below, Thank you for watching us.

ABOUT US

Tutorial Hive’s mission is to provide quality education to all our community. Tutorial Hive’s mission is to provide free education to all those who cannot afford BIG FEE of institutes. We aim specifically to empower youth to understand programming related knowledge which further helps the society to reduce complex problems through applications. Why Tutorial Hive? We not only provide the theoretical knowledge but also provide the actual implementation with working sample applications. Tutorial Hive cannot achieve its mission without the help of our community. So, please if you think you can help in any manner feel free to contact us. Or if you see any mistake in our content which can be modified/corrected then please leave us a message

We are always open for suggestions.

Facebook: www.facebook.com/hbss2015

Subscribe on YouTube: https://www.youtube.com/channel/UCOUy6kTpedj7s6HOqM0c08w

Follow us on Social Media

You might be interested in

LEAVE YOUR COMMENT

Your email address will not be published. Required fields are marked *