Last active
September 16, 2020 17:41
-
-
Save kjohnson/ddd59433f2bdaa8be62e9a9c77f2cccd to your computer and use it in GitHub Desktop.
Sprintf vs Interpolation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Formatted string. | |
echo sprintf( 'This is a known %s being translated.', __( 'Translated String' ) ); | |
// Interpolation | |
extract([ | |
'string' => __( 'Translated String' ) | |
]); | |
echo "This is a user provided ${string}"; | |
echo "This is another user provided ${string}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment