Terms
 

Welcome to the "brucegust.com" Terms page! Recall, revisit, refresh...


Arrays | GIT | NET | OOP | PDO | Terms

 JQuery
 Boilerplate
A Plugin is a JQuery object that does something cool. When you determine that you want to build your own plugin, which is very likely, you'll use what's called a "Boilerplate" to encapsulate your code so any potential redundancy between the syntax you use and code that exists elsewhere in your app doesn't conflict with one another.

This is fairly verbose, but it's not that difficult. Just buckle up...

// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.


;(function ( $, window, undefined ) { // undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
// window and document are passed through as local variables rather than globals
// as this (slightly) quickens the resolution process and can be more efficiently
// minified (especially when both are regularly referenced in your plugin).


// Create the defaults once
var pluginName = "defaultPluginName",
document = window.document,
defaults = {
propertyName: "value"
};


The first thing you should notice is that these variable are defined outside of any functions – the IIFE doesn’t count – which limits the number of instances to 1 (as opposed to 1 for each time the plugin is called or a plugin object is instantiated) and it makes them available to everything within the IIFE. The first variable is pluginName, which should be the name of the function that you are extending jQuery with. It’s referenced on lines 32, 45, 47, and 48. This allows you to change the name of your plugin in one place rather than in all 4 of those places mentioned (and more places if you need to reference it within the code you write). The next variable is document, which is just a reference to the document – often used in jQuery plugins – which allows it to be shortened by minifiers again. The final variable is defaults. Most plugins give users options that they can send in to the plugin and this variable contains the default values for each of the options you offer.

// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;


// jQuery has an extend method which merges the contents of two or
// more objects, storing the result in the first object. The first object
// is generally empty as we don't want to alter the default options for
// future instances of the plugin
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = pluginName;
this.init();
}


This is the constructor for the object that will be doing all the heavy lifting in the plugin. The constructor is pretty minimal, mostly just creating a few instance properties and then leaving the rest up to init. Walking through, this.element holds the DOM element that this plugin is supposed to manipulate, this.options holds an object with all of the options that the user sent in and any defaults that weren’t overridden by the user. The rest are pretty self-explanatory.

Plugin.prototype.init = function () {
// Place initialization logic here
// You already have access to the DOM element and the options via the instance,
// e.g., this.element and this.options
};


The init function where all the logic associated with this plugin’s initialization should be placed.

And finally...

// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
}
});
}
 
 CDN
When you load the JQuery library into your page, rather than have the actual library sitting on your personal server, you'll refer to it using a CDN.

CDN stands for Content Development Network. It's a series of servers scattered around the world. When you use a URL such as this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

...you're system is defaulting to the closest server in the network to access the JQuery library.

Click here for more info.
 
 Constructor
A constructor is used to for initializing new objects. In really simplistic terms, it looks like this:

function Account () {
your logic
}

​// This is the use of the Account constructor to create the userAccount object.​

​var userAccount = new Account (); //notice the use of the word "new"
 
 DOM
DOM stands for "Document Object Model."

In an HTML document, you've got any one of number of elements; <div>, <tr>, <span> etc. The way those things are represented and organized on a page is the "Document Object Model." In JQuery, that's significant because you're usually interacting with specific elements within the DOM and it's because of the structure and organization of the DOM that JQuery can be so useful.
 
 Function Expression vs Function Declaration and IIFE
In JavaScript, there are two basic ways of invoking a function. The most common way is "declaration..."

function myFunction() { logic here }

The other way to do is referred to as an "expression" where the function is part of a larger chunk of syntax. Like this:

var somethingSpecial = function() { logic here }

You can also assign a function to a property (notice the placement of the curly braces);

var myObject = {

myFunction: function) {logic here }

}

Regardless if you're using the Definition or the Expression approach, in both instances you're having to instantiate it with a var or some kind of systemic step.

With IIFE (Immediately Invoked Function Expressions), you're "immediately" invoking the functionality. So, just as soon as the page is accessed, BOOM! All that code kicks on and you're up and running. The big thing, however, is that with IIFE you're able to isolate your code in a way where you can use "var" throughout and not worry about how "var" is used in other sections of your app causing name collisions. The code you would use for that would look like this: (function() { logic here })(); Click here for more information. And here's another link as well...
 
 IIFE
IIFE stands for "Immediately Invoked Function Expression. It's an anonymous function (no name attached to it) that is wrapped inside of a set of parentheses and called (invoked) immediately. This is some of the foundational logic that the Boilerplate dynamic is built upon. For more info, click here.
 
 JQuery
Jquery is a library of JavaScript. What would otherwise represent mountains of code is now simply referred to in the context of JQuery functions.

You'll load the JQuery library in your header like this:

<script src="jquery-3.2.1.min.js"></script>

Now, you've got access to all kinds of functionality that would otherwise require thousands of lines of code.
 
 min
"min" stands for "minify."

The Jquery library with all of the expected white space and line breaks equates to a pretty big file. "min" removes all of the white space. It's really hard to read, but it takes up less room.
 
 Object
A JQuery object is a var, but a whole lot more.

For example, if you have 3 TEXTAREA elements on the page and you do this:

var j = $('textarea');

then this j jQuery object will contain these properties:

0 - reference to the first TEXTAREA element
1 - reference to the second TEXTAREA element
2 - reference to the third TEXTAREA element
length - which is 3
context - reference to the document object
selector - which is 'textarea
'
 
 Plugin
A plugin is a piece of JQuery code that does something cool. There's a whole registry of them that you can access but sometimes you want to create your own plugin in that you're able to create a piece of functionality once and then use it repeatedly without having to rewrite it every time.

Let's say we want to create a plugin that makes text within a set of retrieved elements green. All we have to do is add a function called greenify to $.fn and it will be available just like any other jQuery object method.

$.fn.greenify = function() {
this.css( "color", "green" );
};

$( "a" ).greenify(); // Makes all the links green.

Cool! Click here for more info.
 
 Property
A Property is a variable defined within a function.

Click here for more detailed info.
 
 Scope
Scope in JavaScript is similar to "visibility" in OOP in that it refers to accessibility within your app.

Global means that whatever it is that you're creating or defining is available and accessible anywhere, anytime throughout your entire application. An example would be:

// global scope
var name = 'Todd';

Local means that the entity in question is available only within the function it was created in. Like this:

//global scope out here...

var myFunction = function () {
//local scope in here
var name = 'Todd';
console.log(name); // Todd
};

// Uncaught ReferenceError: name is not defined because you're referring to a var that is "local" in scope console.log(name); For more info, click here
 
 Selector
A Selector in JQuery is what you're using systemically to grab a particular element within the DOM, like a
or a specific field that has a unique id.

Like this:

var theDiv = $("#theDiv");

Now, remember, "theDiv" is a JQuery object which is very cool in that it's more than just a variable. It has properties and other systemic features that can be very cool when it comes to programming.

Click here for more info.
 
 use strict
"use strict" is a piece of code that tells the system not to be sloppy in the way it processes your code. In this way, you're able to avoid some errors that might otherwise occur if the system is being too forgiving.

Strict mode makes it easier to write "secure" JavaScript.

Strict mode changes previously accepted "bad syntax" into real errors.

As an example, in normal JavaScript, mistyping a variable name creates a new global variable. In strict mode, this will throw an error, making it impossible to accidentally create a global variable.

In normal JavaScript, a developer will not receive any error feedback assigning values to non-writable properties.

In strict mode, any assignment to a non-writable property, a getter-only property, a non-existing property, a non-existing variable, or a non-existing object, will throw an error.

Click here for more info.
 
 Laravel
 Installation
definition
 
 NET
 API
"Application Programming Interface." A fancy term to describe all of the builiding blocks that combine to form a computer program of some sort.

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it's a set of clearly defined methods of communication between various software components.

What makes API such an advantage is the way it serves as a "one stop shop" for your business logic so you're not having to reinvent the wheel for every browser, OS etc.
 
 double
double refers to numbers with decimal points.
 
 floating point
Numbers in the computer world are stored as Binary values. In Binary (1's and 0's), you've got a decimal point that "floats." It's not like your typical decimal point in the way it affects the precision of the number. Rather, it's defining the number itself.

For example, the number "4" could potentially look like this as a Binary value: 0000101100. The placement of a decimal point affects the value of that number in whole integers. Compare that to a regular decimal point where you're reflecting precision.
 
 HTTP
Hypertext Transport Protocol. This is the set of rules and protocols the web uses to transport information over the web.

HTTP (Hypertext Transfer Protocol) is the set of rules for transferring files (text, graphic images, sound, video, and other multimedia files) on the World Wide Web. As soon as a Web user opens their Web browser, the user is indirectly making use of HTTP. HTTP is an application protocol that runs on top of the TCP/IP suite of protocols (the foundation protocols for the Internet) (techtarget).

Basically, you're looking at a hierarchy of digital platforms that combine to provide a web based experience. It looks like this:

 
 JSON
Javascript Object Notation. It's Javascript's way of packaging data...

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. (JSON.org)
 
 LAMBA
This is something you'll encounter from time to time as part of the "app.run" portion of the Configure Construct in your Startup Class. Code Project defines it like this:

A lambda expression is an anonymous function and it is mostly used to create delegates in LINQ. Simply put, it's a method without a declaration, i.e., access modifier, return value declaration, and name.

Convenience. It's a shorthand that allows you to write a method in the same place you are going to use it. Especially useful in places where a method is being used only once, and the method definition is short. It saves you the effort of declaring and writing a separate method to the containing class.
 
 LINQ
LINQ (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Microsoft .NET-based programming languages.
 
 Object
An Object is an Instance of a Class. Here's the hierarchy:

Class -> Instance -> Object

Class - a mountain of functionality that is off stage.
Instance - creating a digital placeholder for that "mountain of functionality" that equates to me bringing all of that on to the stage.
Object - engaging that "mountain of functionality" in a way that translates to an actual task or value.

You'll often see "Instance" and "Object" used interchangably. That's not a criminal thing to do but be aware of how "object" refers to a unique "instance" of a class because of the way an object has a the functionality in that Class actually doing something.
 
 REST
This is similiar to the protocol that you see in apps such as Code Igniter. The URL of the site isn't your typical ".htm" or ".php." Rather, it's a cue represented by some text that tells your program what to do. You see this a lot with the .NET architecture you're using.

REST stands for "Representational State Transfer" and it is an architectural pattern for creating an API that uses HTTP as its underlying communication method. REST was originally conceived by Roy Fielding in his 2000 dissertation paper entitled "Architectural Styles and the Design of Network-based Software Architectures", chapter 5 cover REST specifically: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

Almost every device that is connected to the internet already uses HTTP; it is the base protocol that the internet is built on which is why it makes such a great platform for an API. (microsoft.com)

You can see this referenced as one of several options a Microsoft Developer meight consider, as far as the infrastructure they would build atop the SOAP philosophical foundation.
 
 Service Layer
The "layer" that exists between the client and the data that client is interacting with in the context of their visit to your website.
 
 SOAP
Simple Object Access Protocol. Bottom line: This allows different computer languages and platforms to "talk" with one another...

SOAP (Simple Object Access Protocol) is a messaging protocol that allows programs that run on disparate operating systems (such as Windows and Linux) to communicate using Hypertext Transfer Protocol (HTTP) and its Extensible Markup Language (XML). Since Web protocols are installed and available for use by all major operating system platforms, HTTP and XML provide an at-hand solution that allows programs running under different operating systems in a network to communicate with each other. SOAP specifies exactly how to encode an HTTP header and an XML file so that a program in one computer can call a program in another computer and pass along information. SOAP also specifies how the called program can return a response. Despite its frequent pairing with HTTP, SOAP supports other transport protocols as well. (techtarget)

SOAP is the foundation upon which various Microsoft web paradigms have been built. All of them seek to streamline syntax as much as possible while simultaneously providing a universal way to communicate data, text and graphics to different operating systems. Among those platforms you have the following:
  • Web Service
    • It's based on SOAP and returns data in XML form.
    • It supports only HTTP protocol.
    • It is not open source but can be consumed by any client that understands xml.
    • It can be hosted only on IIS.
  • WCF
    • It is also based on SOAP and returns data in XML form.
    • It is the evolution of the web service(ASMX) and supports various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.
    • The main issue with WCF is it's tedious and extensive configuration.
    • It is not open source but can be consumed by any client that understands xml.
    • It can be hosted with in the applicaion or on IIS or using window service.
  • WCF Rest
    • To use WCF as WCF Rest service you have to enable webHttpBindings.
    • It support HTTP GET and POST verbs by [WebGet] and [WebInvoke] attributes respectively.
    • To enable other HTTP verbs you have to do some configuration in IIS to accept request of that particular verb on .svc files
    • Passing data through parameters using a WebGet needs configuration. The UriTemplate must be specified
    • It support XML, JSON and ATOM data format.
  • Web API
    • This is the new framework for building HTTP services with easy and simple way.
    • Web API is open source an ideal platform for building REST-ful services over the .NET Framework.
    • Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats)
    • It also supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing - all of which makes it more simple and robust.
    • It can be hosted with in the application or on IIS.
    • It has a lightweight architecture and is good for devices which have limited bandwidth like smart phones.
    • Responses are formatted by Web API's MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.
When to choose either WCF or WEB API
  • Choose WCF when you want to create a service that should support special scenarios such as one way messaging, message queues, duplex communication etc.
  • Choose WCF when you want to create a service that can use fast transport channels when available, such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transport channels are unavailable.
  • Choose Web API when you want to create a resource-oriented services over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).
  • Choose Web API when you want to expose your service to a broad range of clients including browsers, mobiles, iphone and tablets. (dotnettricks)
 
 WCF
One of several platforms that Microsoft offers that's built upon the SOAP philosophical foundation. See the "SOAP" link at the top of this page.
 
 XML
Extensible Markup Language. "Extensible" means, "capable of being extended." To understand XML, you've got to go back to HTML and unpack what HTML stands for. "HTML stands for "Hypertext Markup Language." "Markup Language" refers to a series of symbols or characters that are inserted in the context of a website or a Word Processing program that programmatically dictate how that text is to appear. <strong><<strong>, for example, is inserted prior to a word to cue the system that it needs to display a text in bold.

XML does the same kind of thing with data. And what makes that so useful is that it not only "communicates" data, it also communicates how that data is to be formatted...

XML code, a formal recommendation from the World Wide Web Consortium (W3C), is similar to Hypertext Markup Language (HTML). Both XML and HTML contain markup symbols to describe page or file contents. HTML code describes Web page content (mainly text and graphic images) only in terms of how it is to be displayed and interacted with.

XML data is known as self-describing or self-defining, meaning that the structure of the data is embedded with the data, thus when the data arrives there is no need to pre-build the structure to store the data; it is dynamically understood within the XML. The XML format can be used by any individual or group of individuals or companies that want to share information in a consistent way. XML is actually a simpler and easier-to-use subset of the Standard Generalized Markup Language (SGML), which is the standard to create a document structure. (techtarget)
 
 Networking
 file:// scheme
You have the option of using "file://" as opposed to "http://" in the context of your web address syntax, but you will generally use "file://" when you're retrieving files from your computer or drives that are mapped to your computer. In other words, you're not venturing out into the world wide web (www) to get your content. Click here for more info.
 
 IP address
"IP" stands for "Internet Protocol." When you're talking about an "IP address," you're referring to the numerical label that's put on every computer that's connected to a network. That could be a local network or it could be a server on the web. Everything has its own IP and that's what allows it to communicate and interact with other computers. Click here for more info.
 
 Permissions
Every website, every computer / server, has "permissions." Different users have different levels of accessibility and those are dictated by the network administrator. Digital Ocean and Microsoft has some good info on this topic.
 
 Ping
When you're wanting to determine whether a particular IP address is valid and there's a legitimate presence on the other side of that value, you use "ping." Open up your command line interface and type in "ping your web address." If it's a valid site / resource, you'll get a return "package" that qualifies it as legitimate. Click here for more info.
 
 PHP
 Class
Some use the illustration of a "blueprint." Bottom line: It's a bunch of functionality that typically includes several methods as well as some other optional "helps" like Constructors and Properties etc.

I like to think of it as a mini-machine. It's represented by a greyed-out button that you have to activate in order for the machine to start running. You activate it by something called "instantiation." At that point, the button is no longer greyed out and you can start taking advantage of whatever functionality it's bringing to the table!

Examples of Classes are found thoughout the samples I've included below.
 
 Constructor
A Constructor assigns some values for you automatically as soon as the Class is instantitated. So, by default you have some data established that can be used by your Class or any "children," should you position your Class to be something another Class might inherit.

You'll need to set up some "Properties" first and then use your Constructor to assign values to those Properties.

Here's an example:

class Spreadsheet {
     public $name; //here's your property
     function __construct() {          
     $this->name="Bruce"; //here's your constructor giving the value "Bruce" to your "name" property          
     echo $this->name;     
     }
}
$new_spreadsheet = new Spreadsheet();

When you run this code, you'll get "Bruce."

 
 Encapsulation
Encapsulation refers to the way in you systemically organize and protect data within a class so it's not accessible to anyone other than methods within the same class. In other words, it's how you keep your data and functionality in the yard so it doesn't go running all over the neighborhood.
 
 Instance
In order to bring the functionality represented by a Class to bear, you have to "instantiate" it. That is, you have to create a Instance of that Class. Once you do that, the "greyed out" button that was that Class is now an "active" button.

It looks like this:

class NewClass {

    public function something_wonderful() {
    
     echo "bring it";
   
     }

}

$say_something=new NewClass; //this is an "Instance" of the NewClass class
 
 JQuery
bring it
 
 MCRYPT_RIJNDAEL_128
You would think that MCRYPT_RIJNDAEL_256 specifies 256-bit encryption, but that is wrong. The three choices specify the block-size to be used with Rijndael encryption. They say nothing about the key size (i.e. strength) of the encryption. (Read further to understand how the strength of the AES encryption is set.)

The Rijndael encyrption algorithm is a block cipher.

A "cipher" is a computer term that refers to an algorithm for performing encryption. A "block cipher" refers an algorithm that's performed on a fixed-length group of "bits.")

It operates on discrete blocks of data. Padding MUST be added such that the data to be encrypted has a length that is a multiple of the block size. (PHP pads with NULL bytes) Thus, if you specify MCRYPT_RIJNDAEL_256, your encrypted output will always be a multiple of 32 bytes (i.e. 256 bits). If you specify MCRYPT_RIJNDAEL_128, your encrypted output will always be a multiple of 16 bytes.

A "bit" is the smallest unit of information that a computer can store. A "byte" is a collection of bits.

Note: Strictly speaking, AES is not precisely Rijndael (although in practice they are used interchangeably) as Rijndael supports a larger range of block and key sizes; AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with key and block sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits. In summary: If you want to be AES compliant, always choose MCRYPT_RIJNDAEL_128.

AES stands for "Advanced Encryption Standard" and is used by the NSA. You generally have two types of encryption: Aesymetric and Symetric. Aesymetric refers to the fact that you have both a public and a private key. Symetric is just one private key.

So the first step is to create the cipher object:

$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');

We're using CBC mode (cipher-block chaining). Block cipher modes are detailed here: http:en.wikipedia.org/wiki/Block_cipher_modes_of_operation

CBC mode requires an initialization vector. The size of the IV (initializationvector) is always equal to the block-size. (It is NOT equal to the key size.) Given that our block size is 128-bits, the IV is also 128-bits (i.e. 16 bytes). Thus, for AES encryption, the IV is always 16 bytes regardless of the strength of encryption.

Here's some PHP code to verify our IV size:

$iv_size = mcrypt_enc_get_iv_size($cipher);
printf("iv_size = %dn",$iv_size);

How do you do 256-bit AES encryption in PHP vs. 128-bit AES encryption??? The answer is: Give it a key that's 32 bytes long as opposed to 16 bytes long.

For example:

$key256 = '12345678901234561234567890123456';
$key128 = '1234567890123456';

Here's our 128-bit IV which is used for both 256-bit and 128-bit keys.

$iv = '1234567890123456';

printf("iv: %sn",bin2hex($iv));
printf("key256: %sn",bin2hex($key256));
printf("key128: %sn",bin2hex($key128));

This is the plain-text to be encrypted:

$cleartext = 'The quick brown fox jumped over the lazy dog';
printf("plainText: %snn",$cleartext);

The mcrypt_generic_init function initializes the cipher by specifying both the key and the IV. The length of the key determines whether we're doing 128-bit, 192-bit, or 256-bit encryption. Let's do 256-bit encryption here:

if (mcrypt_generic_init($cipher, $key256, $iv) != -1)
{
// PHP pads with NULL bytes if $cleartext is not a multiple of the block size..

$cipherText = mcrypt_generic($cipher,$cleartext );
mcrypt_generic_deinit($cipher);

Display the result in hex.

printf("256-bit encrypted result:n%snn",bin2hex($cipherText));
}

Now let's do 128-bit encryption:

if (mcrypt_generic_init($cipher, $key128, $iv) != -1)
{

// PHP pads with NULL bytes if $cleartext is not a multiple of the block size..

$cipherText = mcrypt_generic($cipher,$cleartext );
mcrypt_generic_deinit($cipher);

// Display the result in hex.
printf("128-bit encrypted result:n%snn",bin2hex($cipherText));


Results



You may use these as test vectors for testing your AES implementations...


256-bit key, CBC mode


IV = '1234567890123456'
(hex: 31323334353637383930313233343536)
Key = '12345678901234561234567890123456'
(hex: 3132333435363738393031323334353631323334353637383930313233343536)

PlainText:
'The quick brown fox jumped over the lazy dog'
CipherText(hex):
2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3


128-bit key, CBC mode

IV = '1234567890123456'
(hex: 31323334353637383930313233343536)
Key = '1234567890123456'
(hex: 31323334353637383930313233343536)
PlainText:
'The quick brown fox jumped over the lazy dog'
CipherText(hex):
f78176ae8dfe84578529208d30f446bbb29a64dc388b5c0b63140a4f316b3f341fe7d3b1a3cc5113c81ef8dd714a1c99
 
 Object
Although you'll sometimes hear Instance and Object used interchangeably, there are different.

An Instance of a Class is my having put the key in the ignition and fired it up. It's no longer a dormant piece of machinery, it's running and ready to be engaged.

An Object is something that machine has made - it's a result of that functionality. It looks like this:

class NewClass {    

     public function something_wonderful() {
         
     echo "bring it";
        
    
     }


}

$say_something=new NewClass;
//this is an "Instance" of the NewClass class $shout = $say_something->something_wonderful(); //$shout is an Object of the NewClass Class 
 
 PDO
PHP Data Objects. There are several advantages to using PDO. Here are a couple:

Database Abstraction Layer - an API that allows you to connect with any one of a number of databases.

Prepared Statements - here you're executing your SQL without any data battached to it. This is how you avoid SQL Injection.

So, this:

$sql = "SELECT * from users where email='$email' AND status='$status'"

Becomes this:

$sql="SELECT * FROM users where email=? AND status=?";

...and then you would run the EXECUTE method of this object, so it would look like this:

$stmt=$pdo->prepare("SELECT * FROM users WHERE email=? AND status=?"); $stmt->execute(['email=>$email, 'status=>$status]); $user=$stmt->fetch();
 
 Scope
Scope is a term that refers to the extent to which a variable makes sense. In other words, how logical does that variable appear to another method - one that didn't create the variable to begin with?


You've got four different types of "scope..."

local
function
global
superglobal

Scope is similiar to Visibility, but with Visibility you've got

public
protected
private

So, there is a difference in that scope is more about variables whereas you'll see visibility describing the accessibility of methods and properties more so than variables.

One definition that struck me as being especially clear was, "Scope can be defined as the range of availability a variable has to the program in which it is declared." (tutorialspoint.com)
 
 Static
On occasion, in addition to seeing a variable or a method's visibility qualified in terms of either private, protected or public, you may also see it referenced as "static." "Static" is a handy tool in that it doesn't have to be instantiated. It can directly accessed using the Scope Resolution Operator(::). For example: $con=DatabaseFactory::CreateLegacyAegisHealthConnection(); CreateLegacyAegisHealthConnection() is a static function in the DatabaseFactory Class. I didn't have to write: $new_con=new DatabaseFactory(); $new_connection=$new_con->CreateLegacyHealthConnection(). I just used the Scope Resolution Operator and, "BAM!" it's right there! Same dynamic applies to both Methods and Properties.
 
 Superglobal Variable

Global variables are accessible from any class, method or function from anywhere in the application. Public, Private, Protected, Child, Parent - doesn't matter. If it's a Superglobal variable, you can grab it and use it and you only have to define it once.

An example would be $_SESSION. That's considered a Superglobal variable in that PHP knows what $_SESSION is. You still have to give it a value, but you don't have to "define" $_SESSION anymore than you have to "define" $_POST or $_GET. PHP knows what those variables are. Again, you still have to give them a value, but systemically, PHP is not looking for that variable, it already knows what it is.

You have the same kind of utility available to you with a "Global" variable, but, unlike a Superglobal variable, you have to define it. Whereas $_SESSION is understood by PHP, $george, on the other hand, is a total mystery.

$george could be your database connection, but in order to give it "wings" so it can fly freely throughout your app, you have to make it a global variable like this:

Here's your database connection script:

$mysqli = new mysqli($host,$user,$password,$database);
if($mysqli->connect_errno) {  
$err="CONNECT FAIL: "  
.$mysqli->connect_errno  
. ' '  
.$mysqli->connect_error  ;  
trigger_error($err, E_USER_ERROR);
}

Now here's my class:

class List {
 
     public spreadsheet () {
          global $mysqli;
          $sql="select * from table";
          $query=$mysqli->query($sql);

     }

}

I've just told my code to go look for $mysqli. It could be anywhere, but by prefacing $mysqli with "global," I'm giving my code permission to go and look anywhere and everywhere for the $mysqli variable.

 
 Visibility
Visibily is something similiar to Scope, but it's more for methods and properties.

There are three types of visibility which are described below:

/**  * Define MyClass  */

class 
MyClass {     

public 
$public 'Public'
;    
protected 
$protected 'Protected'
;     
private 
$private 'Private'
;
    
     function 
printHello
(){         
     echo 
$this->public
;         
     echo 
$this->protected
;         
     echo 
$this->private
;     
     }
}

$obj 
= new MyClass
();
echo 
$obj->public
// Works
echo $obj->protected
// Fatal Error
echo $obj->private
// Fatal Error
$obj->printHello(); 
// Shows Public, Protected and Private

/**  * Define MyClass2  */

class MyClass2 extends 
MyClass {     
// We can redeclare the public and protected method, but not private     

    
public $public 'Public2'
;     
    protected 
$protected 'Protected2'
;
    
     function 
printHello
(){         
     echo 
$this->public
;         
     echo 
$this->protected
;         
     echo 
$this->private
;     
     }
}

$obj2 
= new MyClass2
();
echo 
$obj2->public
// Works
echo $obj2->protected
// Fatal Error
echo $obj2->private
// Undefined $

obj2
->printHello(); 
// Shows Public2, Protected2, Undefined

?>

public: Public properties and methods can be accessed anywhere in a script after the object has been instantiated

protected: Protected properties and methods can be accessed only within the class that defines them, parent classes, or inherited classes

private: Private properties and methods can only be accessed by the class that defines them