Open In App

PHP | Imagick getRegistry() Function

Last Updated : 28 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The Imagick::getRegistry() function is an inbuilt function in PHP which is used to get the StringRegistry entry for the named key or false if not set.

Syntax:

string Imagick::getRegistry( string $key )

Parameters: This function accepts a single parameter $key which holds the key.

Return Value: This function returns a string value containing the value associated with the key.

Exceptions: This function throws ImagickException on error.

Below given programs illustrate the Imagick::getRegistry() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Get the Registry
$registry = $imagick->getRegistry('key');
echo $registry;
?>


Output:

// Empty string because no registry with key as 'key' is set.

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Registry
$imagick->setRegistry('key', 'my_value');
  
// Get the Registry
$registry = $imagick->getRegistry('key');
echo $registry;
?>


Output:

my_value

Reference: https://www.php.net/manual/en/imagick.getregistry.php


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads