class User { private $id; private $name; // Constructor public function __construct($id, $name) { $this->id = $id; $this->name = $name; } // Get ID function public function getID() { return $this->id; } } // Usage example $user = new User(1, "John Doe"); $userID = $user->getID(); echo $userID; // Output: 1
class Product { private $id; private $name; private $price; // Constructor public function __construct($id, $name, $price) { $this->id = $id; $this->name = $name; $this->price = $price; } // Get ID function public function getID() { return $this->id; } } // Usage example $product = new Product(1, "Apple", 0.50); $productID = $product->getID(); echo $productID; // Output: 1Package library: This specific function is not part of any package library in PHP. However, it may be used in conjunction with other libraries such as database ORMs that require unique IDs for each model instance.