Decompsoing a structure into its individual parts is called de structuring.
PHP var_export() Function
Outputs or returns a parsable string representation of a variable. It will gives you structured information about the given variable.
Syntax :
var_export ( mixed $expression [bool $return = FALSE ]);
$expression – The variable you want to export.
$return – This is optional. If it is used and set to true then it will return the variable representation instead of outputting it else it will return NULL.
Example :
$x = array("red", "green", "blue");
echo var_export($x);
Output:
array ( 0 => 'red', 1 => 'green', 2 => 'blue', )
Pushing to a Remote Branch with a Different Name
You just have to run the following command
git push origin local-name:new-name-for-remote
How to Install Composer In Your Project ?
Run this in your command line:
curl -sS https://getcomposer.org/installer | php
For more information please follow.
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
How to remove primary key from table?
ALTER table table_name
DROP PRIMARY KEY;
How to add primary key in table?
ALTER table table_name
ADD PRIMARY KEY column_name;
How to search JSON data in MySQL?
If you have JSON type columns in your database and want to run query on JSON type field. You can use the following query.
SELECT JSON_EXTRACT('<json_column>', "$.response") AS name
FROM table
WHERE JSON_EXTRACT('<json_column>', "$.id") > 3
In the above query <json_column> must be replace by your column name.
$.id and $.response contains the JSON key of your columns. You can use for multiple values also.
For example : $.response.name
How to redirect from http to https using .htaccess ?
Redirect to https
If you want to redirect each request coming should go to https instead of HTTP without any plugin. then
Step1: Go to root directory of your website and look for .htaccess file. It should be exist in root directory.
Step2: Find the ‘RewriteEngine On’ Add the following code after that.
1 2 | RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L] |
Here yourdomain stands for website name for which you want to redirect to https.
How to create custom helper functions in Laravel 5?
From the laravel official
Laravel includes a variety of global "helper" PHP functions. Many of these helper functions are used by the framework itself; however, you are free to use them in your own applications if you find them convenient.
Helpers are pre built utility functions in laravel which we can use directly without any class import/extend. e.g. str_random() – generates a random string of the specified length.
dd() – dumps the given variables and ends execution of the script.
We can also create our own helpers in laravel. Here are the steps.
Step1 : Create a folder in app folder with named Helpers(You can create with other name also).
Step2 : Now create a file with name helpers.php(You can create with other name also) file in Helpers folder
Step3 : Add the utility functions in that file.
Step3 : Now add the open composer.json locate autoload block and add the following line
"files": ["app/Helpers/helpers.php"] |
Step3 : Now,load it up with composer – composer dump-autoload
Now you can use your utility functions anywhere in the application.
Popular php repositories on github
If you want to know which php repositories are popular or trending on github now.
Follow the following URL :