PHP code example of mehedimi / new-instance
1. Go to this page and download the library: Download mehedimi/new-instance library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mehedimi / new-instance example snippets
use Mehedi\NewInstance\NewInstance;
class Post
{
use NewInstance;
public function find()
{
//
}
}
// Then
Post::newInstance()->find();
$post1 = Post::newSingleInstance();
$post2 = Post::newSingleInstance();
// Here $post1 and $post2 object are same
use Mehedi\NewInstance\NewInstance;
class Post
{
use NewInstance;
public function __construct($hello, $word)
{
//
}
}
Post::newSingleInstance('hello', 'word');
// OR
Post::newInstance('hello', 'word');