Title: How to call php in link using insert php?
Last modified: August 22, 2016

---

# How to call php in link using insert php?

 *  Resolved [driveweb](https://wordpress.org/support/users/driveweb/)
 * (@driveweb)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/how-to-call-php-in-link-using-insert-php/)
 * Hey everyone,
 * My client needs to use this php function:
 *     ```
       <?php
               $fh = fopen("http://driveweb.com/tech/ap/version.txt", 'r');
               $data = fgets($fh);
               $data = fgets($fh);
               fclose($fh);
               $build = trim(substr($data, 13));
       ?>
       ```
   
 * This uses the $build variable to setup the correct (i.e. latest) URL:
 * `<a href="http://driveweb.com/tech/ap/<?php echo $build ?>/dw.jnlp">link goes
   here</a>`
 * I have used the [insert_php] shortcode within the function itself, but how would
   I amend the above href to work with this shortcode? Thanks!!
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/how-to-call-php-in-link-using-insert-php/#post-5720691)
 * Hi driveweb,
 * The PHP code between the [insert_php] and [/insert_php] tags must be complete
   in itself. There is no outside scope.
 * This page is handy for reference about that and other limitations you may encounter:
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php)
 * Perhaps a solution to the issue you presented is to let the PHP code echo the
   link. Something like this:
 *     ```
       [insert_php]
       $fh = fopen("http://driveweb.com/tech/ap/version.txt", 'r');
       $data = fgets($fh);
       $data = fgets($fh);
       fclose($fh);
       $build = trim(substr($data, 13));
       echo "<a href=\"http://driveweb.com/tech/ap/$build/dw.jnlp\">link goes here</a>";
       [/insert_php]
       ```
   
 * Will
 *  Thread Starter [driveweb](https://wordpress.org/support/users/driveweb/)
 * (@driveweb)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/how-to-call-php-in-link-using-insert-php/#post-5720696)
 * Will,
 * Thanks SO much that is exactly what I was looking for! I am not too knowledgeable
   in the realm of php. I was trying to put $build in the url but was forgetting
   the \ in the hyperlink.
 * Again, thanks so much!
    – Julian
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/how-to-call-php-in-link-using-insert-php/#post-5720788)
 * Gratuitous post to mark topic resolved.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to call php in link using insert php?’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/how-to-call-php-in-link-using-insert-php/#post-5720788)
 * Status: resolved