Posts

PHP Output Statements

 In PHP, we can get output by two ways, 1) echo 2) print PHP echo and print Statements echo  and  print  are more or less the same. They are both used to output data to the screen. The differences are small:  echo  has no return value while  print  has a return value of 1 so it can be used in expressions.  echo  can take multiple parameters (although such usage is rare) while  print  can take one argument.  echo  is marginally faster than  print . SHOW TEXT <?php echo   "<h2>PHP is Fun!</h2>" ; echo   "Hello RK!<br>" ; echo   "I'm about to learn PHP!<br>" ; echo   "This " ,  "string " ,  "was " ,  "made " ,  "with multiple parameters." ; ?> SHOW VARIABLE <?php $txt1 =  "Learn PHP" ; $txt2 =  "With RK" ; $x =  5 ; $y =  4 ; echo   "<h2>"  . $txt1 .  "</h2>" ; echo   "Study PHP "  . $txt...

PHP Variables

  In PHP, a variable starts with the  $  sign, followed by the name of the variable: for example: <?php $txt =  "Hello RK!" ; $x =  5 ; $y =  10.5 ; ?> A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for PHP variables: A variable starts with the  $  sign, followed by the name of the variable A variable name must start with a letter or the underscore character A variable name cannot start with a number A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive ( $age  and  $AGE  are two different variables) NOTE: Remember that PHP variable names are case-sensitive! Output The PHP  echo  statement is often used to output data to the screen. The following example will show how to output text and a variable: Example 1: <?php $txt =  "RK" ; echo   "I love $txt!" ; ?> Example 2:...

PHP Comments

  Comments in PHP A comment in PHP code is a line that is not executed as a part of the program. Its only purpose is to be read by someone who is looking at the code. Comments can be used to: Let others understand your code Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code PHP supports several ways of commenting: Single Line Commenting < !DOCTYPE  html > < html > < body > <?php // This is a single-line comment # This is also a single-line comment ?> < /body > < /html > Multi line Commenting < !DOCTYPE  html > < html > < body > <?php /* This is a multiple-lines comment block that spans over multiple lines */ ?> < /body > < /html >

How to install and setup PHP?

  What Do I Need? To start using PHP, you can: Find a web host with PHP and MySQL support Install a web server on your own PC, and then install PHP and MySQL Use a Web Host With PHP Support You can simply download Xampp or Wampp Server on your PC. Just Search "Download Xampp for windows 7" (Or whatever your OS windows 7, Windows 10 etc). Click any site on google and download xampp server. Install it and setup. You can setup Xampp by finding any Video on Youtube. First program in PHP After successful installation of Xampp Server on your PC, Go to C://Xampp/htdocs Create here any folder and then create a new file with .php extention. For example crate a folder named 'TEST' and then enter to this folder. Test create a file 'test.php' with the code written below: <?php $txt =  "PHP" ; echo   "I love  $txt! " ; ?> Now go to your browser and open your file with localhost/YourFfolderName/YourFileName.php For Example localhost/test/test.ph...

Brief Intro of PHP

  What You Should Already Know Before you continue you should have a basic understanding of the following: 1) HTML 2) CSS 3) JAVASCRIPT What is PHP? PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use What is a PHP File? PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP code is executed on the server, and the result is returned to the browser as plain HTML PHP files have extension " .php " What Can PHP Do? PHP can generate dynamic page content PHP can create, open, read, write, delete, and close files on the server PHP can collect form data PHP can send and receive cookies PHP can add, delete, modify data in your database PHP can be used to control user-access PHP can encrypt data With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML an...

Learn Php

Image
What is php? PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP 7 is the latest stable release. Example: <!DOCTYPE html> <html> <body> <?php echo "Hello RK. This is PHP example."; ?>  </body> </html>