Top 10 Tips Advanced PHP Developers

Top 10 Tips Advanced PHP Developers

Today, We want to share with you Top 10 Tips Advanced PHP Developers.
In this post we will show you 10 Things You Can Do to Become a Better PHP Developer, hear for The 10 Most Common Example PHP Developers we will give you demo and example for implement.
In this post, we will learn about 10 Advanced PHP Tips with an example.

Read Also:  Advanced jQuery Ajax Pagination PHP MySQL using jQuery

php generate random string of characters

$string = 'DEFCHJJ0123ABC4DSw2waycomP567pakainfo89';
$string_shuffled = str_shuffle($string);
$half = substr($string_shuffled, 1, 4);
echo $half;

PHP urlencode() & urldecode() Functions


php convert special characters to html entities


log genrater file created using PHP

function wh_log($msg)
	$logfile = 'log/log_' . date('d-M-Y') . '.log';
    file_put_contents($logfile, $msg . "\n", FILE_APPEND);

/*wh_log("########## END[IN FUNCTION getpartylistf($unitid,warehouseid)]'" . date('d-m-Y H:i:s') . "'##########"); */

lastInsertId using PHP script example

$sql="INSERT INTO `usermst` (`userid`, `usermobile`, `regdt`, `status`, `deviceid`, `device_token`) VALUES (NULL, '$mobile', '$dt', '0', '$deviceid', '$dtokenf')";
					wh_log("sqlquery" . $sql);
					$db = getConnection();
					$sqlQQ =  $db->prepare($sql);
					$new_userid = $db->lastInsertId();

INNER JOIN in mysql with PHP Example

$partySS="select usermst.userid,usermst.usermobile from usermst 
INNER JOIN usergroupmap
ON usermst.userid=usergroupmap.userid
where usergroupmap.groupid=$gid and usermst.userid  $userid ORDER BY userid DESC";

PHP Total No of Records Count using PHP

$deviceT = "SELECT DISTINCT device_token FROM usermst where trim(device_token) != '' and status=5 and userid='$userid'";

$db = getConnection();       
$deviceTStmnt = $db->prepare($deviceT);
$deviceTData = $deviceTStmnt->fetchAll(PDO::FETCH_ASSOC);
$deviceTCount = count($deviceTData);

php json_decode to array with php json_encode to array – example

	error_reporting(E_ALL || ~E_NOTICE);
	$user_name = $_POST['name'];
	$user_username = $_POST['username'];
	$user_email = $_POST['email'];
	$user_phone1 = $_POST['phone1'];
	$user_phone2 = $_POST['phone2'];
	$user_password = $_POST['password'];
	$req_sub = $_POST['req_sub'];//产品ID
		foreach($req_sub as $v){
	echo "<pre>";
	echo "</pre>";

how to check whether session exists or not in php


	$check = $_SESSION['login_username'];

	if(!isset($check)) {

Demo – Source code

Read Also:  jQuery AJAX file Image upload PHP Example

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Login with Facebook and Twitter using PHP
  2. Read Also:  AngularJS populate Dynamic Dependent dropdown in PHP
  3. Read Also:  PHP MySQL Connect Database Script
  4. Read Also:  Laravel JSON Encode Decode Handling
  5. Read Also:  Laravel Set cron job in cpanel Scheduling Tutorial
  6. Read Also:  Laravel 6 Eloquent Query Retrieving Single Models
  7. Read Also:  Menu Based Program in PHP Using Switch case
  8. Read Also:  How to Get Last Executed Query in Codeigniter?
  9. Read Also:  Menu Based Program in PHP Using Switch case
  10. Read Also:  PHP MySQL Connect Database Script