Skip to main content

Posts

Showing posts with the label PHP

PHP variable and constant

What is variable?  A variable is a representation of a value. Let's take for instance, A=40; the representation of 40 is A, so A is called the variable. For storing information,  a variable can be called "containers". Rules for variable  1. Add a $ (dollar sign) in front or before the variable name. For example: $No_of_oranges 2. The PHP cannot begin with numerals; despite the fact of adding the dollar sign ($) in front of the variable name. The variable name must begin with alphabets or underscore sign(_). 3. The PHP variable may contain the following characters: Numerals: (0-9) Alphabets: (A-Z) or (a-z)  Underscore: (_) 4. PHP variables are case sensitive. ie. $No_of_oranges and $NO_OF_ORANGES are different variable 5. Variable name can be any length long. Variable Types: 1. Scalar types: Boolean Integer Float String 2. Compound types: Object Array 3. Special types: Resource  Null Let's take an example: <?php $string...

PHP First Program

Syntax  Recall: From our last post we discussed about syntax, but let's take an insight. Below are the opening and closing syntax of a php. Opening tags: <?php <? <script language='php'> Closing tags: ?> ?> (short tag) </script> PHP echo  The echo statement helps in inserting words into a web page. The echo statement is used more often in PHP. A statement can be echoed using the following types: Single Quote Double Quotes Without Quote "here document" method  Let's take a "hello simply lecture" example: <?php echo 'hello simply lecture';  //single quote echo "hello simply lecture"; //double quote echo hello simply lecture; //without quote echo <<<END hello simply lecture END; ?>

PHP Basic Concept

What is PHP? PHP stands for "Hypertext processor" and was initially called "personal home page". PHP does not charge users, hence it is free to download and use. PHP is designed for web use as a scripting language and works only with web server. Examples are: Apache, IIS, nginx etc. which means that the PHP script only runs in web servers. It is an HTML-embedded scripting language. Syntax The opening and closing tags of PHP syntax includes: Opening tags: <?php <? <script language='php'> Closing tags: ?> ?> (short tag) </script> Note:  To use syntax 2 of the closing tags, short tags must be turned "on" in php.ini located at the php.ini file. To turn this on use: short_open_tag=on PHP file The extension of PHP file is (.php). The PHP files contains codes from html, css, java script, user text and php code. The method of code execution in PHP is called "sever side code" but when the code is execute...