Title: readonly
Published: November 20, 2017
Last modified: February 24, 2026

---

# readonly( mixed $readonly_value, mixed $current = true, bool $display = true ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#wp--skip-link--target)

This function has been deprecated since 5.9.0. Use [wp_readonly()](https://developer.wordpress.org/reference/functions/wp_readonly/)
instead.

Outputs the HTML readonly attribute.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#description)󠁿

Compares the first two arguments and if identical marks as readonly.

This function is deprecated, and cannot be used on PHP >= 8.1.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#see-also)󠁿

 * [wp_readonly()](https://developer.wordpress.org/reference/functions/wp_readonly/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#parameters)󠁿

 `$readonly_value`mixedrequired

One of the values to compare.

`$current`mixedoptional

The other value to compare if not just true.

Default:`true`

`$display`booloptional

Whether to echo or just return the string.

Default:`true`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#return)󠁿

 string HTML attribute or empty string.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#source)󠁿

    ```php
    function readonly( $readonly_value, $current = true, $display = true ) {
    	_deprecated_function( __FUNCTION__, '5.9.0', 'wp_readonly()' );
    	return wp_readonly( $readonly_value, $current, $display );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-compat/readonly.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/php-compat/readonly.php#L34)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/php-compat/readonly.php#L34-L37)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_readonly()](https://developer.wordpress.org/reference/functions/wp_readonly/)`wp-includes/general-template.php` |

Outputs the HTML readonly attribute.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/readonly/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Deprecated. Use [wp_readonly()](https://developer.wordpress.org/reference/functions/wp_readonly/) introduced in 5.9.0. | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Freadonly%2F)
before being able to contribute a note or feedback.