There is no performance difference, because the result of get_bloginfo() comes from an internal cache anyway, because most (all?) of the return values come from get_option() calls, and these are cached internally with wp_cache_set() and fetched with wp_cache_get(). See Exploring the WordPress Cache API.
Even if there would be a difference it would be too small to be relevant.
The more important difference is readability. This is easier to read and less error prone:
$template_dir = get_template_directory_uri();
foreach ( array ( 1, 2, 3 ) as $n )
echo "<img src="https://wordpress.stackexchange.com/questions/107279/$template_dir/data1/images/$n.jpg" alt="">";
Related Posts:
- Nginx FastCGI_Cache Vs PHP Caching
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Extremely slow pageload for long post when using the_content?
- Performance issues with large website [closed]
- Why does running get_the_excerpt() when generating JSON file take 28 seconds vs. 599 milliseconds without it?
- PHP 5.5, w3 Total Cache, and opcache [closed]
- Looking for most performant way to execute several similar WP queries within shortcodes
- It is a good idea to store values from the global $post if they are used multiple times?
- WordPress Script stops suddenly
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- Page load timer?
- Can/should we delete wordpress cron jobs with no action?
- How do you measure the PHP generation time of your WordPress pages?
- Huge time to first byte on live site
- Serve cookie free URLs in WordPress without using a CDN
- (Xdebug Profiler) Why are there two cachegrind files generated for one page?
- Create page in templates for pages or the pages manager?
- Perfmon performance counters on WAMP
- WordPress article with 50 000 words loading slow – 100% cpu
- In WordPress how do you remove render-blocking CSS manually without a plugin?
- How to check if woocommerce is activated in theme
- Call to a member function add_rewrite_tag() on null
- Detect a focus on wp_editor
- Failed media upload: “The uploaded file was only partially uploaded.”
- Utilize WP-CLI from inside WordPress, not SSH
- How to link to a custom .php page in my folder
- How to execute a simple php script in WP (I don’t think wp_enque_script applies here)
- get_transient(), PHP switch(), and comparison operators
- Front end submit form with jquery form plugin
- WP_Query meta_query results date by date
- Rewrite sub folder dynamically with country code in WordPress using PHP
- allow users to publish without admin approval
- Use WordPress’ URL rewrite engine
- Upload Image in a WordPress page using PHP
- Get Custom URL For Custom Taxonomy
- How to add custom post meta to default blog post?
- Shortcode content filter?
- only show container with next/prev links if they exist?
- JS file work only in index page
- Update grandchild repeater field with value per row
- Paypal form integration with wordpress registration form without plugin [closed]
- How to get the value of input hidden html from text editor to custom page template?
- Uploading files using the Settings API
- fatal error call to undefined function get_header in index.php on line 1
- Plugins not working on AJAX requests
- If has $title in widgets
- get href content [closed]
- Illegal string offset in PHP function
- Displaying text if post was within 5 hours
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- How to say if meta_value is greater than 0 in an array?
- Adding a tag_ID column into Categories inside the admin dashboard?
- How to get category name or ID by post?
- ACF Repeater Pagination stopped working since upgrade to php7.2
- Using featured image of blog archive page
- Best Way to Change a String in a WordPress Post
- Show get_sub_field value if it exists [closed]
- How to wrap every 3 posts in a div (and close the last div too) [closed]
- Dividing the loop to style post differently
- How to Display a List of Child Pages For a Parent Page in WordPress
- Why, when moving a WordPress multisite network, have my theme customisations stopped working?
- include content within conditional statement?
- How to change the author box selection on a post to a custom taxonomy
- How to send a php var to jQuery Ajax call with two different file
- User meta needed in query is serialized – how to unserialize safely?
- PHP calling AJAX function that relies on passed PHP function values not working
- Order by title Child Pages displayed in a Parent Page
- not outputting medium size image URL
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Intermittent problem can the debug log give any clues?
- Echo short code syntax
- WordPress recent post
- Show subcategory name selected in specific category woocoommerce
- Add custom attribute to product’s HTML to woocommerce cart page
- Decoding an array in PHP (from the Shopify API) [closed]
- PHP is_embed error showing up
- How fix error in the WordPress loop?
- PHP Session Variable to WordPress Error
- Run code before WordPress loads and insert data into WP if need be
- Editing existing pre-created menus in PHP
- need help to arabic text in wordpress
- Sorting Meta Fields?
- Themes with variable width or single columns? I want to display source code
- Category List in Theme Options Page
- Showing all post from all post type in admin backstage
- Or operators in PHP [closed]
- upload images on front by user using form
- how to iterate through xml data?
- What does this if-statement do?: if($pages=’ ‘) {}
- Really slow WordPress site [closed]
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- understanding wp_next_scheduled
- WordPress 6.1.1 UTF8 Slug Limit Increase
- WordPress directories not writable after PHP version upgrade
- How do I unset category from a product in wordpress by code
- How can I make below code to show grouping by country ranks in same div, example if in second loop rank 2nd must be show in same 2nd class div
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Load style and script for custom post type metabox
- Permissions error when I use my plugin to delete comments in the front-end