CODE:
<?php
$fname = "Tom";
$lname = "Hanks";
$newFname ;
$fname = $newFname ?? $fname;
echo $fname;
$newFname= "Jon";
$fname = $newFname ?? $fname;
echo "<br>";
echo $fname;
?>
Simple Web Development tips & spiritual observations
CODE:
<?php
$fname = "Tom";
$lname = "Hanks";
$newFname ;
$fname = $newFname ?? $fname;
echo $fname;
$newFname= "Jon";
$fname = $newFname ?? $fname;
echo "<br>";
echo $fname;
?>
Code:
<?php
class StudentInfo{
public $name;
public $age;
private $mobileNum;
public function setMobileNum($mobileNum){
$this->mobileNum=$mobileNum;
}
public function getMobileNum(){
return $this->mobileNum;
}
}
$student = new StudentInfo();
$student -> name ="Tommy Jones";
$student -> age =45;
print_r($student);
$student->setMobileNum('11111111');
echo "<br>";
print_r($student);
$jsonEncoded=json_encode($student);
echo "<br>";
print_r($jsonEncoded);
$jsonDecoded=json_decode($jsonEncoded);
echo "<br>";
print_r($jsonDecoded);
$jsonDecodedArray=json_decode($jsonEncoded,true);
echo "<br>";
print_r($jsonDecodedArray);
?>
Only Public ones will be converted
Code:
<?php
class studentInfo{
public $name;
public $age;
private $mobileNum;
public function setMobileNum($mobileNum){
$this->mobileNum=$mobileNum;
}
public function getMobileNum(){
return $this->mobileNum;
}
}
$student = new studentInfo();
$student->name= "Tom hanks";
$student->age = 45;
$student->setMobileNum('11111111');
//echo $student->getMobileNum();
echo json_encode($student);
?>
CODE:
<?php
$studentNum=0;
if(isset($studentNum)){
echo "value is set ";
}else{
echo "value not set";
}
echo "<br>";
if(empty($studentNum)){
echo "value is empty";
}else{
echo "value not empty";
}
echo "<br>";
if(isset($studentNum) && (is_numeric($studentNum) || $studentNum !='')){
echo "there is value and not empty";
}else{
echo " not set or empty";
}
?>
OUTPUT:
value is set
value is empty
there is value and not empty
CODE:
<?php
/*** remove key and data from associative array PHP */
$studentInfo =["name"=>"Tomy Jason","age"=>45,"sex"=>"Male"];
print_r($studentInfo);
unset($studentInfo["sex"]);
echo "<br>";
print_r($studentInfo);
?>
Code:
<?php
$customer= [
"name"=>"Tommy Jason",
"age" => 45,
"sex" => "Male",
"location" => "USA"
];
print_r($customer);
echo "Serialized: <br>";
$serializedCustomer =serialize($customer);
echo $serializedCustomer;
echo "<br>";
echo "Unserialized: <br>";
$unserializedCustomer =unserialize($serializedCustomer);
print_r($unserializedCustomer);
echo "<br>";
echo "JSon Encoded<br>";
echo $jsonEncoded = json_encode($customer);
echo "<br>";
echo "Json Decoded --converted to object <br>";
$jsonDecoded= json_decode($jsonEncoded);
print_r($jsonDecoded);
echo "<br>Json Decoded --converted to Array <br>";
$jsonDecoded= json_decode($jsonEncoded,true);
print_r($jsonDecoded);
echo "<br>";
?>
Code:
<?php
$students=[
'12'=>'Tom',
'13'=>'Shib',
'14'=>[
'12'=>'Tom Spanish',
'13'=>'Shib Spanish'
]
];
var_dump($students);
echo "<br>";
print_r($students);
echo "<br>";
echo $students["14"]["13"];
echo "<br>";
$food=array(
"vegetables" => "tomato,potato",
"frutis" => "apple, banana",
"drinks" => array(
"soft"=>"coke,fanta",
"beverage" => "x,y,z",
)
);
print_r($food);
echo "<br>";
echo $food["drinks"]["soft"];
?>
Here I am sharing you my observation regarding Jupiter Sukshma Dasha and Saturn Prana Antardasha
Continue reading “Jupiter Saturn Precaution and Observation”
If you are using both the W3 Total Cache and WP Touch Pro plugins for optimizing your site’s performance and mobile view respectively, you may encounter a conflict where WP Touch Pro stops displaying the mobile view and instead shows the cached desktop version.
Here is the Solution
Continue reading “Resolving WP Touch Pro Mobile View Conflict with W3 Total Cache: Fixing Desktop Cache Display Issue”
If you are using Smart Theme V3 by Optimizepress and you are searching to add some basic social icons at the end of blog post ( which you edited using Optimizepress builder), then use the code i shared here. It will be looked like this ( almost similar)
