Title: PO::export_headers
Published: April 25, 2014
Last modified: April 28, 2025

---

# PO::export_headers(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/po/export_headers/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/po/export_headers/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/po/export_headers/?output_format=md#related)

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

Exports headers to a PO entry

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

 string msgid/msgstr PO entry for this PO file headers, doesn’t contain newline 
at the end

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

    ```php
    public function export_headers() {
    	$header_string = '';
    	foreach ( $this->headers as $header => $value ) {
    		$header_string .= "$header: $value\n";
    	}
    	$poified = PO::poify( $header_string );
    	if ( $this->comments_before_headers ) {
    		$before_headers = $this->prepend_each_line( rtrim( $this->comments_before_headers ) . "\n", '# ' );
    	} else {
    		$before_headers = '';
    	}
    	return rtrim( "{$before_headers}msgid \"\"\nmsgstr $poified" );
    }
    ```

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

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

| Uses | Description | 
| [PO::poify()](https://developer.wordpress.org/reference/classes/po/poify/)`wp-includes/pomo/po.php` |

Formats a string in PO-style

  | 
| [PO::prepend_each_line()](https://developer.wordpress.org/reference/classes/po/prepend_each_line/)`wp-includes/pomo/po.php` |

Inserts $with in the beginning of every new line of $input_string and returns the modified string

  |

| Used by | Description | 
| [PO::export()](https://developer.wordpress.org/reference/classes/po/export/)`wp-includes/pomo/po.php` |

Exports the whole PO file as a string

  |

## User Contributed Notes

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