Introduction to PHP – Syntax

Introduction to PHP – Syntax

 

So let’s start creating our first PHP file. The extension for PHP files is .php. You can create a .txt file and just rename it to extension to index.php for example. The name index.php is typically rendered automatically by accessing you domain name.

PHP Code:

<?php 
echo "<h1>My first PHP page!</h1>"; 
?>

This will give you:

my first PHP page

Things to remember about PHP

Now let’s stop for a moment and take a look at our code. We can see that it starts with “<?php” and ends with “?>” and we are using echo to output some HTML content. We used quotation marks to wrap the content and we end the line with a semicolon.

There are also some other things to remember:

  • White spaces, tablations and line jumps are ignored in PHP.
  • Although functions names like ECHO, IF, ELSE, WHILE, etc, are all case insensitive. we can not say the same about variable names. For example $MyVar is not the same as $myVar and both are different from $myvar.
  • We can use “//” to create single line comments or “/*” and “*/” for multiple line comments
PHP Code:

<?php 

// this is a simple variable in PHP
$myVar = "myVar has been set";

echo "<p>This PHP output uses lowercase echo</p>"; 
ECHO "<p>Here we are using uppercase ECHO</p>"; 
Echo "<p>And here we are using Capitalized Echo</p>";

echo $myVar;

?>

Case sensitive example.

 

PHP text editors

While you don’t need any special editor to create PHP files there are some that are better than others. And since this depends on everybody’s tastes and programming background, you can choose one from the list above

  • Notepad++ – It’s the most basic editor for various programming languages including PHP. You can download Notepadd++ here: http://notepad-plus-plus.org/
  • NetBeans IDE – Is a free open-source Integrated Development Environment (IDE) for software developers. Pretty cool if you ask me. You can check it out here: https://netbeans.org/
  • Sublime Text – Sublime text editor is one of my favorite. It is quite cool for novice and advanced users. You can use it out of the box and you have tons of options to customize. It is suppose to came as trial…buy you don’t have to buy it if you don’t want. Go ahead and download it if you like: http://www.sublimetext.com/

Of course there are tones of editors that you can use. Please feel free to leave me a comment and let me know which one is your favorite. You can also find a good list of some other PHP editors on Wikipedia website located here: https://en.wikipedia.org/wiki/List_of_PHP_editors

Python Example for Beginners

Two Machine Learning Fields

There are two sides to machine learning:

  • Practical Machine Learning:This is about querying databases, cleaning data, writing scripts to transform data and gluing algorithm and libraries together and writing custom code to squeeze reliable answers from data to satisfy difficult and ill defined questions. It’s the mess of reality.
  • Theoretical Machine Learning: This is about math and abstraction and idealized scenarios and limits and beauty and informing what is possible. It is a whole lot neater and cleaner and removed from the mess of reality.

Data Science Resources: Data Science Recipes and Applied Machine Learning Recipes

Introduction to Applied Machine Learning & Data Science for Beginners, Business Analysts, Students, Researchers and Freelancers with Python & R Codes @ Western Australian Center for Applied Machine Learning & Data Science (WACAMLDS) !!!

Latest end-to-end Learn by Coding Recipes in Project-Based Learning:

Applied Statistics with R for Beginners and Business Professionals

Data Science and Machine Learning Projects in Python: Tabular Data Analytics

Data Science and Machine Learning Projects in R: Tabular Data Analytics

Python Machine Learning & Data Science Recipes: Learn by Coding

R Machine Learning & Data Science Recipes: Learn by Coding

Comparing Different Machine Learning Algorithms in Python for Classification (FREE)

Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.  

Google –> SETScholars