PHP Live Clock with JQUERY

Buat File jam.php

<?php
    date_default_timezone_set('Asia/Jakarta'); // atau timezone lain
    echo $timestamp = date('H:i:s');

Tambahkan script js di bagian bawah halaman,

$(document).ready(function() {
    setInterval(timestamp, 1000);
});

function timestamp() {
    $.ajax({
        url: 'http://localhost/jam.php',
        success: function(data) {
            $('#timestamp').html(data);
        },
    });
}

Untuk menampilkan, tambahkan tag <div> seperti di bawah ini

<div id="timestamp"></div>

Enable PHP 5.6 CURL Extension Ubuntu Server 14.04 LTS

Source: https://stackoverflow.com/questions/38800606/how-to-install-php-curl-in-ubuntu-16-04

In Ubuntu 16.04 default PHP version is 7.0, if you want to use different version then you need to install PHP package according to PHP version:

  • PHP 7.2: sudo apt-get install php7.2-curl
  • PHP 7.1: sudo apt-get install php7.1-curl
  • PHP 7.0: sudo apt-get install php7.0-curl
  • PHP 5.6: sudo apt-get install php5.6-curl
  • PHP 5.5: sudo apt-get install php5.5-curl

Google Map API v3 Biostall Libary

Demo: http://biostall.com/demos/google-maps-v3-api-codeigniter-library/

Download: https://github.com/BIOSTALL/CodeIgniter-Google-Maps-V3-API-Library/archive/master.zip

  • Download library (ukuran ~ 190KB)
  • Paste di direktori Application/libraries. Ada dua file, Googlemaps.php dan Jsmin.php
  • Pada file view.php (atau file apapun untuk menampilkan map) sebelum tag </head> paste script di bawah ini

<?php echo $map['js']; ?>

  • dan paste script di bawah ini untuk menampilkan map di antara tag <body> dan </body>

<?php echo $map['js']; ?>

PHP 7.0:  Error Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP

jika Anda memakai PHP7 maka akan ada error di baris atas website seperti ini

pada file Application/libraries/Googlemaps.php

ubah baris di bawah ini


function Googlemaps($config = array()) {

menjadi seperti ini


function __construct($config = array()) {

tampilan editornya

CodeIgniter HMVC object_to_array() error

HMVC : https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads

Muncul error

An uncaught Exception was encountered

Type: Error

Message: Call to undefined method MY_Loader::_ci_object_to_array()

Filename: /Users/k1ut2/Sites/nine.dev/application/third_party/MX/Loader.php

Line Number: 300

Backtrace:

File: /Users/k1ut2/Sites/nine.dev/application/controllers/Welcome.php Line: 23 Function: view

File: /Users/k1ut2/Sites/nine.dev/index.php Line: 315 Function: require_once

Solusi:

pada file application/third_party/MX/Loader.php (sekitar line 300…)


return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));

replace dengan script di bawah ini


if (method_exists($this, '_ci_object_to_array'))
{
 return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
} else {
 return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
}