SlideShare a Scribd company logo
1 of 17
PHP Basic Part 1
Overivew
Objective
For beginners to learn the basics of PHP. PHP is required
for using ProdigyView.
Requirements
 Willingness To Learn
 General knowledge of programming
Estimated Time
10 minutes


                    http://www.prodigyview.com
Follow Along With A Code
          Example
1. Download a copy of the example code at
  www.prodigyview.com/source.

2. Install the system in an environment you feel
  comfortable testing in.

3. Proceed to examples/basics/PHP_Basics_2.php




                   http://www.prodigyview.com
Concepts To Cover
 Variables
 Arrays
 Defines
 Functions
 Objects
 Challenge!
 Review


                http://www.prodigyview.com
Welcome
Before you start using ProdigyView, you need to have
some of the basics down in PHP. This tutorial is for
people who have some programming experience but are
relatively new to programming in PHP.

This tutorial is no where covers everything but will
hopefully cover enough to get you started on the learning
process.

You will need to play around with the code to get a good
understanding of these concepts.



                    http://www.prodigyview.com
VariablesDepending on if you have
The best place to start in PHP is with variables.
used other languages like Java, C++, Objective-C you will likely be use to
defining a variable by giving it a type, name and a value.
Examples:
 int anumber = 1;
 boolean opened = true;
 String[] mystrings = new String[15];
In PHP it is a little simpler. All have to do is assign a value to a variable.
Variables start with the dollar($) sign and are case sensitive. After the dollar
sign, variables can either start with a letter or underscore, followed by any
combination of letters, underscore or numbers.




                    The equal sign sets the value of the variables
DEFINES
 Defines are variables that are made global. This means
  that the variable can be accessed anywhere in the
  code, including functions and in objects.
 Following PHP coding standards, when setting a
  define, they should always be capitalized.
 Once a define is set, it cannot be changed.




1. Name of the Define       2. Value assigned to the define
Variables Can Be Anything
Variables are not only values such as integers and strings
but can also be object and arrays. In an more advanced
tutorial we will set variables to be structures such as
anonymous functions. But for now, understand that a
variable can be anything.




                    http://www.prodigyview.com
Arrays
So now that we have variables down, we can move on to
arrays. Arrays are a collection of variables. If you use
arrays in other languages then you might be use to setting
an array size or setting the index of an array as a numeric
value. In PHP you do not have to set the array size and
an index can be either a string or integer.
                 1. Explicitly set the index of an array




    2. The array() function creates an array whose index can be assigned
Iterating Arrays
After you get use to creating arrays, the next step is
iterating through them. Iterating through an array will allow
you to get the values entered into the array. Also arrays
can be combined to create a new array with the values of
both array.
                               Key is the index and value is value of the index




Add two arrays to create a new array
Functions
     Next stop, the function in PHP. Functions is code that can
     be executed when called. Functions contain variables and
     variables can passed to functions. When functions are
     defined outside of a class, they can be called anywhere in
     your code.

      1. Define Function         2. Represents values to be passed to the function




4.Call/Execute Function    3. Returns a value to the location the function was called
Objects
We’ve covered variables, arrays and functions. All of
those attributes can go inside of an object. Objects are
defined by a ‘class’. When a function is inside an class, it
is then referred to as a method.

Inside an class, the attributes can have three states:
public, private and protected. We will get more into this in
another tutorial.

Like other languages, object can be initialized or
instantiated(able to be accessed) with the keyword ‘new’.



                     http://www.prodigyview.com
Object Example
1. Define the Class
                           2. Create method within class




          4. Call method                3. Instantiate Object
Challenge!
Now we should have some basic understanding of PHP.
To better understand variables, functions and objects,
complete this challenge. Keep in mind there is no right
answer.

Create an object that had methods for adding,
subtracting, multiplying and dividing numbers. Store the
return results in an array and iterate through that array.




                     http://www.prodigyview.com
The Not So Obvious
1. Using ‘echo’ or ‘print’ will print/display the value of a
   variable to the user.

2. The ‘return’ in a function will return a value to the
   place the function was called.

3. Using ‘//’ will allow you to leave comments in the code.
   Comments are ignored by the compiler and will not
   affect your code.

4. To call a method in an object, use the ->. The arrow
   should point to the name of the method.

           Example: $object->methodName()
                     http://www.prodigyview.com
Review
1. Variables can be anything: Arrays, Objects, String,
   Booleans, Integers, etc

2. Array are data structures that hold multiple variables
3. Functions is code that completes a task and can be called
   from anywhere in execution

4. Functions inside an object is called a method and can only
   be accessed through that object

5. Objects are data structures that contain functions and
   variables.

6. Defines are non-mutable variables that are accessible
   anywhere in the code execution.
                      http://www.prodigyview.com
More Tutorials
For more tutorials, please visit:

http://www.prodigyview.com/tutorials




                     www.prodigyview.com

More Related Content

More from ProdigyView

More from ProdigyView (20)

Audio Content Management
Audio Content ManagementAudio Content Management
Audio Content Management
 
File Content Management
File Content ManagementFile Content Management
File Content Management
 
Email Configuration
Email ConfigurationEmail Configuration
Email Configuration
 
HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements Tutorial
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags Tutorial
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHP
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHP
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHP
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS Libraries
 
PHP Libraries
PHP LibrariesPHP Libraries
PHP Libraries
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design Pattern
 
Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHP
 
PV Standard Search Query
PV Standard Search QueryPV Standard Search Query
PV Standard Search Query
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Learning PHP Basics Part 1

  • 2. Overivew Objective For beginners to learn the basics of PHP. PHP is required for using ProdigyView. Requirements  Willingness To Learn  General knowledge of programming Estimated Time 10 minutes http://www.prodigyview.com
  • 3. Follow Along With A Code Example 1. Download a copy of the example code at www.prodigyview.com/source. 2. Install the system in an environment you feel comfortable testing in. 3. Proceed to examples/basics/PHP_Basics_2.php http://www.prodigyview.com
  • 4. Concepts To Cover  Variables  Arrays  Defines  Functions  Objects  Challenge!  Review http://www.prodigyview.com
  • 5. Welcome Before you start using ProdigyView, you need to have some of the basics down in PHP. This tutorial is for people who have some programming experience but are relatively new to programming in PHP. This tutorial is no where covers everything but will hopefully cover enough to get you started on the learning process. You will need to play around with the code to get a good understanding of these concepts. http://www.prodigyview.com
  • 6. VariablesDepending on if you have The best place to start in PHP is with variables. used other languages like Java, C++, Objective-C you will likely be use to defining a variable by giving it a type, name and a value. Examples:  int anumber = 1;  boolean opened = true;  String[] mystrings = new String[15]; In PHP it is a little simpler. All have to do is assign a value to a variable. Variables start with the dollar($) sign and are case sensitive. After the dollar sign, variables can either start with a letter or underscore, followed by any combination of letters, underscore or numbers. The equal sign sets the value of the variables
  • 7. DEFINES  Defines are variables that are made global. This means that the variable can be accessed anywhere in the code, including functions and in objects.  Following PHP coding standards, when setting a define, they should always be capitalized.  Once a define is set, it cannot be changed. 1. Name of the Define 2. Value assigned to the define
  • 8. Variables Can Be Anything Variables are not only values such as integers and strings but can also be object and arrays. In an more advanced tutorial we will set variables to be structures such as anonymous functions. But for now, understand that a variable can be anything. http://www.prodigyview.com
  • 9. Arrays So now that we have variables down, we can move on to arrays. Arrays are a collection of variables. If you use arrays in other languages then you might be use to setting an array size or setting the index of an array as a numeric value. In PHP you do not have to set the array size and an index can be either a string or integer. 1. Explicitly set the index of an array 2. The array() function creates an array whose index can be assigned
  • 10. Iterating Arrays After you get use to creating arrays, the next step is iterating through them. Iterating through an array will allow you to get the values entered into the array. Also arrays can be combined to create a new array with the values of both array. Key is the index and value is value of the index Add two arrays to create a new array
  • 11. Functions Next stop, the function in PHP. Functions is code that can be executed when called. Functions contain variables and variables can passed to functions. When functions are defined outside of a class, they can be called anywhere in your code. 1. Define Function 2. Represents values to be passed to the function 4.Call/Execute Function 3. Returns a value to the location the function was called
  • 12. Objects We’ve covered variables, arrays and functions. All of those attributes can go inside of an object. Objects are defined by a ‘class’. When a function is inside an class, it is then referred to as a method. Inside an class, the attributes can have three states: public, private and protected. We will get more into this in another tutorial. Like other languages, object can be initialized or instantiated(able to be accessed) with the keyword ‘new’. http://www.prodigyview.com
  • 13. Object Example 1. Define the Class 2. Create method within class 4. Call method 3. Instantiate Object
  • 14. Challenge! Now we should have some basic understanding of PHP. To better understand variables, functions and objects, complete this challenge. Keep in mind there is no right answer. Create an object that had methods for adding, subtracting, multiplying and dividing numbers. Store the return results in an array and iterate through that array. http://www.prodigyview.com
  • 15. The Not So Obvious 1. Using ‘echo’ or ‘print’ will print/display the value of a variable to the user. 2. The ‘return’ in a function will return a value to the place the function was called. 3. Using ‘//’ will allow you to leave comments in the code. Comments are ignored by the compiler and will not affect your code. 4. To call a method in an object, use the ->. The arrow should point to the name of the method. Example: $object->methodName() http://www.prodigyview.com
  • 16. Review 1. Variables can be anything: Arrays, Objects, String, Booleans, Integers, etc 2. Array are data structures that hold multiple variables 3. Functions is code that completes a task and can be called from anywhere in execution 4. Functions inside an object is called a method and can only be accessed through that object 5. Objects are data structures that contain functions and variables. 6. Defines are non-mutable variables that are accessible anywhere in the code execution. http://www.prodigyview.com
  • 17. More Tutorials For more tutorials, please visit: http://www.prodigyview.com/tutorials www.prodigyview.com