$abc = "abc.jpg";
$def = explode('.', $abc);  converts string to array
$ghi = end($def); - display last in tha array
echo $ghi;

in_array("23", $people)-check in array

trim(string,charlist) -remove white space

global $x, $y; $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];

@ - error control operator

htmlspecialchars($str) - shows the html itself without converting

serialize
encode

When the left part is an object instance, you use ->. Otherwise, you use :: 

strip_tags()- t

extract()


htmlspecialchars - HTML escaped code

These variables are called attribute of the object once an object is created.


-------------


	                          	OOPS

Member variable - variable inside class
Member function - function inside class


Abstract class - cannot be instantiated (obj), only inherited (sub class)

Static Keyword-*Declaring class members or methods as static makes them accessible without needing an instantiation of the class.
*A member declared as static can not be accessed with an instantiated class object (though a static method can).

Final Keyword-prevents child classes from overriding a method


Static class method:

add_filter( 'media_upload_newtab', array( 'My_Class', 'media_upload_callback' ) );

Instance method:

add_filter( 'media_upload_newtab', array( $this, 'media_upload_callback' ) );


--------------------

you can make it static variable, so you will be able to call it anytime anywhere, the diff is that instead of

$this->lang;

when editing it(Works inside class game only) you do :

self::$lang;
and when you call/edit it (Works everywhere) from anther class you do :

game::$lang


-----------------

private - class
protected - class, sub class
public - class, sub class, object


$var = "way";
echo "Two {$var}s to define a variable in a string.";


---------

git clone URL
1.git pull orgin master

git config - user name nd pwd

git branch
git status
git commit -m "msg" {wpcontent} - replacing existing files
git add {filepath} - adding new files
git commit
git status
git push orgin master

Codeignitor

DB config - /applications/config/database.php
Base URL config - /applications/config/config.php
Route config - /applications/config/routes.php
Autoload files - /applications/config/autoload.php

Controller:
class Page extends CI_Controller 

		$this->load->model('users');
		$this->load->view($data['theme'].'/page', $data);

Google Crawl

Crawling is the process by which Googlebot discovers new and updated pages to be added to the Google index.
Google search console - to test
https://www.google.com/webmasters/tools/
https://www.google.com/webmasters/tools/googlebot-fetch?hl=en&siteUrl=https://fletcherchiropracticllc.com/

Onload


      window.addEventListener("load",foo);
      window.addEventListener("load",bar);
      function foo(){
        alert("this");
      }
      function bar(){
        alert("that");
      }



window.onload = function () { .... };

Dynamic class method invocation in PHP

call_user_func() and call_user_func_array()

Closure

$msg = 'Hello';

 $closure = function () use ($msg) {

    var_dump($msg);

 };

 $closure();

Tips

*expected return needs to be at last.. check conditions before that and return it, if it fails. *handle error first

Upgrading xampp PHP version on windows

Step 1: First download the latest php version from http://windows.php.net/download#php-7.0
Step 2: Download the VC14 x86(for PHP 7.0) Thread Safe or VC14 x64(for PHP 7.0) Thread Safe deciding upon your Windows version( x86 for 32-bit and x64 for 64-bit ).
Step 3: Next extract the zip file in a folder and rename php.
Step 4: Go to your XAMPP installation directory and rename your old php directory with old version prefix like php to php_5_6_36. Now copy & paste the extracted new php folder to here.
Step 5: Next, open httpd-xampp.conf from XAMPP configuration.
On PHP-Module setup section, comment these two lines and add the two lines below # # PHP-Module setup # #LoadFile “D:/xampp/php/php5ts.dll” #LoadModule php5_module “D:/xampp/php/php5apache2_4.dll” LoadFile “D:/xampp/php/php7ts.dll” LoadModule php7_module “D:/xampp/php/php7apache2_4.dll” Step 6: Now restart your XAMPP server and keep coding.
Step 7: Error Handling: 1. Close the SKYPE, may be PORT issue. 2. The XAMPP may be in x86 but the PHP is x64(see architecture in phpinfo() below changing the php) 3. Navigate to XAMPP, click apache_start.bat. a cmd prompt will be displayed with detailed error info. 4. phpmyadmin issue - no php.ini file, add the php.ini file.

Interface - OOPS

Implements Interface is like blue print of class.
eg: interface aaa{
	public function bb(){}
}

class implementing the aaa should have bb() function else will throw an error.
class abc implements aaa{
	public function bb(){
		echo "bb";
	}
}

REST(Represententional State Transfer) API

1.If we need to get the weather of a location we need to set sensor throughout the city but it cost more money. 2.We can get the weather data from webservices(webservices is something like web sever and we accessing it). Here comes rest api. 3. In which format server responds in JSON or XML is called "representation". 4. The data is mentioned as "resource". 5. The rest is design archieture. 6. address of thre resource - URI http://www.example.com/UK/london must have one URI(uk)
The difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other.
Any web service that is defined on the principles of REST can be called a RestFul web service.
REST is a set of rules/standards/guidelines for how to build a web API.

JSON

PHP FUNCTIONS *glob() *list()
Cookies - Inculded in every http request. Stored in server. local storage - stored in client machine. Size is bigg compared to cookies.

Consuming API

We can use both file_get_contents and CURL for consuming APIs. You might consider using cURL if: You need a very finely tuned request. You don’t have allow_url_fopen allowed on your system. You need multiple parallel handlers You want to handle timeout settings (I guess these all go with the finely tuned request theme)

JOOMLA

COMPONENTS - main functional units displayed in the template, linke CMS, form etc. Module - like widget, latest news Extension - Components, languages, modules, plugins and templates collectively known as Extensions. https://stackoverflow.com/questions/1478220/difference-between-components-modules-extensions-and-plugins-in-joomla 1. Navigate to menu and check the "link". link: index.php?option=com_users&view=registration Disable "Search Engine Friendly URLs" in the Global Configuration com_users - represents it is a component and its is in component/com_users/ Basically a task in joomla 2.5 represents a function in a controller of your component. When you have an url like index.php?option=com_foo&task=comment.edit the function "Edit" in the controller Comment of the component com_foo is called. For example here is a controller DPAttachmentsControllerAttachment with a download function The url looks like index.php?option=com_dpattachments&task=attachment.download.

Error Reporting

Use php_value in .htaccess:

use php_value for setting ini-settings that need a value:
php_value memory_limit 64M
use php_flag for settings that are binary switches:
php_flag log_errors on
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Unfortunately, these two directives won’t be able to display parse errors such as missing semicolons or missing curly braces. In this case, the PHP ini configuration must be modified.
error_reporting(E_ALL & ~E_NOTICE);
The “~” character means “not” or “no” so the parameter ~E_NOTICE means not to show notices. ini_set — Sets the value of a configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. We can modify the php.ini on the server, it will relect on all the sites under that server, else add php.ini on the root of the site and add the required changes. check "Loaded Configuration File" on phpinfo(). ON godaddy, for php 5 use php5.ini
What are the different types of errors in PHP? There are four types of errors in PHP. Parse Error (Syntax Error): The parse error occurs if there is a syntax mistake in the script; Fatal Error: Fatal errors are caused when PHP understands what you’ve written, however what you’re asking it to do can’t be done. Warning Error: Warning errors will not stop execution of the script. The main reason for warning error is to include a missing file or using the incorrect number of parameters in a function. Notice Error: Notice error is the same as a warning error i.e. in the notice error, execution of the script does not stop. Notice that the error occurs when you try to access the undefined variable, then produce a notice error.

Php Functions

The extract() function imports variables into the local symbol table from an array.

Difference between composer prefer-dist and prefer-source?

Dist: The dist is a packaged version of the package data. Usually a released version, usually a stable release. Source: The source is used for development. This will usually originate from a source code repository, such as git. You can fetch this when you want to modify the downloaded package.

Socail media share

fb: https://www.facebook.com/sharer/sharer.php?u=example.org twitter: http://www.twitter.com/share?url= linkedin: https://www.linkedin.com/shareArticle?mini=true&url=

convert an object into array

$name_of_array = (array) $name_of_object; get_object_vars($obj)? Seems useful if you only want to access the public properties of an object.

Offset in array

From were to start the array
Php is executed before the page is pushed to the client and javascript is excuted as the page is loading in the browser (although it is often benificial to tell the browser to not execute it until the entire page is loaded) and after event on the loaded page. The only way to get the variable back to the php interpreter is to call the page again passing variables, or use an ajax call to the server.
$fp = fopen("data_new_insta.php","w"); $temp = array(); $temp['token'] = $this->token; $temp['uname'] = $this->uname; fwrite($fp,print_r($temp,true)); fclose($fp);
function writeLog($data) { $CI = get_instance(); if ($CI->session->userdata('username')){ $username=$CI->session->userdata('username'); } else $username='unknown'; $currdate = date('Y-m-d H:i:s'); $currmonth=date('Ym'); $data2="----------------------------------------------------\n"; $data2.='Action performed by '.$username.' at '.$currdate.":\n".$data." \n"; file_put_contents(APPPATH.'/logs/apidatapulls_'.$currmonth.'.txt', $data2, FILE_APPEND | LOCK_EX); }
function remove_http($url) { $disallowed = array('http://', 'https://'); foreach($disallowed as $d) { if(strpos($url, $d) === 0) { return str_replace($d, '', $url); } } return $url; } In some cases "CURLOPT_RETURNTRANSFER" in CURL may produce error, if removed the output cant be able to in the variable. If we need to assign value to the variable "output buffer". ob_start(); $address_response = ob_get_clean(); Best Practice: filter_var($_POST["jform"]["email1"], FILTER_VALIDATE_EMAIL);
Hash function hashpass($password){ $password = hash("SHA512", base64_encode(str_rot13(hash("SHA512", str_rot13($password))))); return $password; }