Title: Basic::__construct
Published: March 29, 2023
Last modified: November 8, 2023

---

# Basic::__construct( array|null $args = null )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#wp--skip-link--target)

Constructor

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#parameters)󠁿

 `$args`array|nulloptional

Array of user and password. Must have exactly two elements

Default:`null`

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct($args = null) {
    	if (is_array($args)) {
    		if (count($args) !== 2) {
    			throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs');
    		}

    		list($this->user, $this->pass) = $args;
    		return;
    	}

    	if ($args !== null) {
    		throw InvalidArgument::create(1, '$args', 'array|null', gettype($args));
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/requests/src/auth/basic.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/Requests/src/Auth/Basic.php#L49)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/Requests/src/Auth/Basic.php#L49-L62)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wporg-requests-auth-basic/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0](https://developer.wordpress.org/reference/since/2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwporg-requests-auth-basic%2F__construct%2F)
before being able to contribute a note or feedback.