Skip to main content

Posts

Showing posts from August, 2020

Class

1. Class Before you begin to code you should make a plan, objected oriented programming is all about making a plan. A class is a plan. Now each of you try to think about making a plan following me. For instance my plan is about a cookie factory. I want to make a cookie factory in order to produce cookies for selling. Without thinking no more, I will create a class called Cookie: <?php class Cookie { } ?> 2. Property My cookies will have some features like color, weight, quantity, price. These features or properties are stored in variables. By the way, what is a variable? 2.1 Variables, Strings, Numbers The variable is a place in computer’s memory where a value like string or number is stored. <?php $color = ’black’; $color = ”red”; $quantity = 3; ?> Note that a variable in php always starts with $ sign. Also note that a statement ends with a semicolon. Strings (or letters) are always enclosed in single or double quotes. So my class till ...

Intro

Intro .php PHP code will be put in a file with extension .php . The most important php file is index.php which is also the page that the server searches when the site is accessed by users. When the user searches inside his browser for a specific website, the browser sends a request to the server where the site is stored, and more precisely to the index.php page of the site, which is the gateway to the site. Usually index.php file is placed in the root folder of the website. It is mandatory to insert opening php tag before coding. If html code is not followed by the php code then closing tag may be missing. Best practices tell us that at the end of the script we should put php closing tag: <?php  // code   ?> Comments The comments are very important for programmer. If we want to comment one single line we should use double slash (//) in front of the code or #sign.   <?php   // $number = 3;   # $number = 3;   ?> If there ...