Supported Versions: PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8
Create GMP number
<?php gmp_init(int|string $num, int $base = 0): GMP
<?php $model = CustomCasts::create([
'address' => new AddressModel('address_line_one_value', 'address_line_two_value'),
'amount' => gmp_init('1000', 10),
'string_field' => null,
]);
<?php $another_model = CustomCasts::create([
'address_line_one' => 'address_line_one_value',
'address_line_two' => 'address_line_two_value',
'amount' => gmp_init('500', 10),
'string_field' => 'string_value',
]);
<?php $model = CustomCasts::create([
'address' => new AddressModel('address_line_one_value', 'address_line_two_value'),
'amount' => gmp_init('1000', 10),
'string_field' => 'string_value',
]);
<?php $model = CustomCasts::create([
'address' => new AddressModel('address_line_one_value', 'address_line_two_value'),
'amount' => gmp_init('1000', 10),
'string_field' => 'string_value',
]);
<?php $model = CustomCasts::create([
'address' => new AddressModel('address_line_one_value', 'address_line_two_value'),
'amount' => gmp_init('1000', 10),
'string_field' => 'string_value',
]);
<?php public function get($model, $key, $value, $attributes)
{
return gmp_init($value, 10);
}
<?php public function testCastGmp()
{
$gmpString = gmp_init('1234');
$gmpOctal = gmp_init(010);
$gmp = gmp_init('01101');
$gmpDump = <<<EODUMP
<?php public function testCastGmp()
{
$gmpString = gmp_init('1234');
$gmpOctal = gmp_init(010);
$gmp = gmp_init('01101');
$gmpDump = <<<EODUMP
array:1 [
<?php {
$gmpString = gmp_init('1234');
$gmpOctal = gmp_init(010);
$gmp = gmp_init('01101');
$gmpDump = <<<EODUMP
array:1 [
"\\x00~\\x00value" => %s