Skip to content

Instantly share code, notes, and snippets.

<?php
// dibutuhkan untuk proses deserialisasi object
include("classa.inc");
$s = file_get_contents('store');
$a = unserialize($s);
// menampilkan data dengan method tampilkan()
echo "Data yang disimpan pada proses serialisasi dari Page 1 adalah :<br/>";
echo "<h1> ";
<?php
if (isset($_POST['Enter'])) {
if(!empty($_POST['text'])) {
include("classa.inc");
$a = new A($_POST['text']);
$s = serialize($a);
// menyimpan variabel $s disuatu tempat yang bisa ditemukan oleh page2.php
if(file_put_contents('store', $s)) {
<?php
class MyClass
{
public $var1 = 'value 1';
public $var2 = 'value 2';
public $var3 = 'value 3';
protected $protected = 'protected var';
private $private = 'private var';
<?php
class A
{
public $text;
public function tampilkan() {
echo $this->text;
}
public function __construct ($x) {
<?php
class A
{
public $foo = 1;
}
$a = new A;
$b = $a; // $a and $b are copies of the same identifier
// ($a) = ($b) = <id>
<?php
class A
{
public static function who()
{
echo __CLASS__;
}
public static function test()
{
<?php
class A
{
public static function who()
{
echo __CLASS__;
}
public static function test()
<?php
//Class where we are going to implement typehinting
class Typehinting_Test{
//Implementation Type Hinting in PHP
//Forcing to pass argument as object of class Test1
public function type_hint_method(Test1 $parameter)
{
$parameter->test_method();
}
}
<?php
function bool2str($bool)
{
if ($bool === false) {
return 'FALSE';
} else {
return 'TRUE';
}
}
<?php
class test
{
public $a;
private $b;
function __construct($a, $b)
{
$this->a = $a;