Podcast
Questions and Answers
What is a characteristic of procedural programming languages?
What is a characteristic of procedural programming languages?
What is an object in object-oriented programming?
What is an object in object-oriented programming?
What is a benefit of PHP being an open source language?
What is a benefit of PHP being an open source language?
What is a characteristic of object-oriented languages?
What is a characteristic of object-oriented languages?
Signup and view all the answers
Who is credited with the first release of PHP in 1995?
Who is credited with the first release of PHP in 1995?
Signup and view all the answers
What is a class in object-oriented programming?
What is a class in object-oriented programming?
Signup and view all the answers
What is the official PHP website?
What is the official PHP website?
Signup and view all the answers
What is the result of the flow of a program in a procedural language when it encounters a function or method?
What is the result of the flow of a program in a procedural language when it encounters a function or method?
Signup and view all the answers
What is the primary benefit of using procedural programming languages?
What is the primary benefit of using procedural programming languages?
Signup and view all the answers
What is a characteristic of object-oriented programming?
What is a characteristic of object-oriented programming?
Signup and view all the answers
Study Notes
PHP Variables
- A variable in PHP is a "container" for storing information and starts with the $ sign, followed by the name of the variable.
- 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 (ageandage and ageandAGE are two different variables).
Variable Scope
- PHP has three different variable scopes: local, global, and static.
- A variable declared outside a function has a global scope and can only be accessed outside a function.
- A variable declared within a function has a local scope and can only be accessed within that function.
- The global keyword is used to access a global variable from within a function.
- PHP also stores all global variables in an array called $GLOBALS[index].
PHP The static Keyword
- Normally, when a function is completed, all of its variables are deleted.
- The static keyword is used to make a local variable not be deleted, allowing it to be used for further tasks.
PHP is a Loosely Typed Language
- PHP automatically associates a data type to the variable, depending on its value.
- PHP is a loosely typed language, which means that the data types are not set in a strict sense, allowing for flexibility in coding.
- In PHP 7, type declarations were added, giving multiple ways to complete a particular task.
Procedural Language
- PHP is a procedural programming language.
- A procedural language includes functions/methods that can be called from the main flow of the program.
- The flow of the program jumps to the function/method, executes the code within the module, and then returns to the next statement in the main flow of the program.
Object-oriented Language
- PHP is also an object-oriented language.
- An object-oriented language uses classes and objects.
- Classes are similar to blueprints, describing what an object can contain, including properties/variables and functions/methods.
- An object is an instance of a class, and objects are naturally encapsulated by containing all related functions/methods and properties/variables within the object itself.
PHP is an Open Source Language
- PHP is an open-source language.
- Each version of the language is created using input from the individuals who use it—the programmers themselves.
- This allows the language to evolve and float into the direction that is driven by the users.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of PHP variables scope, including local, global and static scopes.