Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Last active September 16, 2020 17:41
Show Gist options
  • Save kjohnson/ddd59433f2bdaa8be62e9a9c77f2cccd to your computer and use it in GitHub Desktop.
Save kjohnson/ddd59433f2bdaa8be62e9a9c77f2cccd to your computer and use it in GitHub Desktop.
Sprintf vs Interpolation
<?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