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:  Top 10 Most Handsome Men in the World

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:  Load More Data from Database using vue.js Ajax PHP

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Functions of a DBMS - Database Management System
  2. Read Also:  how to compare two strings in PHP if condition?
  3. Read Also:  PHP nested FOR loop multiple conditions - ArrayIterator
  4. Read Also:  strstr in php
  5. Read Also:  About prevNext - first‹ prevnext ›last
  6. Read Also:  Laravel Pass Array whereIN clause Example using query builder
  7. Read Also:  Laravel User Role based Access control Authentication
  8. Read Also:  jQuery Ajax Upload Multiple Images using PHP
  9. Read Also:  About prevNext - first‹ prevnext ›last
  10. Read Also:  PHP nested FOR loop multiple conditions - ArrayIterator