Search
 
SCRIPT & CODE EXAMPLE
 

PHP

constructor in php

<?php
class Car {
  public $name;
  public $color;

  function __construct($name) {
    $this->name = $name;
  }
  function get_name() {
    return $this->name;
  }
  function get_color() {
    return $this->color;
  }
}
$mycar = new Car("Audi");
$mycar->color = "red";

echo $mycar->get_name(); // Audi
echo $mycar->get_color(); // red
Comment

construct php

class Example1
{
   public $cache_file;

   function __construct()
   {
      // some PHP code...
   }

   function __destruct()
   {
      $file = "/var/www/cache/tmp/{$this->cache_file}";
      if (file_exists($file)) @unlink($file);
   }
}

// some PHP code...

$user_data = unserialize($_GET['data']);

// some PHP code...
Comment

PREVIOUS NEXT
Code Example
Php :: sum multiple fields separately in laravel 
Php :: repeater acf 
Php :: wordpress disable editor 
Php :: php compare strings case insensitive 
Php :: Laravel validation for checkboxes 
Php :: yii2 redirect with 301 
Php :: laravel update single field 
Php :: php mysql datetime format string 
Php :: wordpress my account url 
Php :: string date less than now php 
Php :: if post id is wordpress php 
Php :: laravel date validation 
Php :: laravel access controller method from another controller 
Php :: validate timestamp php 
Php :: php JSON_PRETTY_PRINT and ? 
Php :: how to claer the input php 
Php :: have_rows count acf php 
Php :: php validate name 
Php :: get one column in all associative array in collection laravel 
Php :: get current route laravel 
Php :: date add one day php 
Php :: take fraction of number in laravel 
Php :: php loop through months 
Php :: install symfony ubuntu 
Php :: migration bool type eloquent orm 
Php :: phpunit filter 
Php :: php hide decimals if zero 
Php :: php access json object 
Php :: how to display list of all pages in wordpress 
Php :: get current user email wordpress 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =