Title: acessing PHP library in functions.php
Last modified: July 30, 2017

---

# acessing PHP library in functions.php

 *  [ragulin](https://wordpress.org/support/users/ragulin/)
 * (@ragulin)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/)
 * Hey guys,
 * I have downloaded [http://simplehtmldom.sourceforge.net/](http://simplehtmldom.sourceforge.net/)
   library into my wp-content. Now I want to include this file into my function 
   in functions.php.
 * But I dont know what kind of URL I should use here. Please, can you give me an
   advice? The code:
 *     ```
       function foobar_func( $atts ){
       require_once('URL path?/simple_html_dom.php');
       $html = file_get_html('http://hokejbal.cz/1-liga/tabulky/');
       $ret = $html->find('table.standings', 1);
       print $ret;
       ```
   

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364431)
 * a “require” statement uses a file path, not a URL.
 *  Thread Starter [ragulin](https://wordpress.org/support/users/ragulin/)
 * (@ragulin)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364458)
 * ok, so it would be the FTP path?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364471)
 * It would be a relative path to the location of functions.php.
 *  [Carl Alberto](https://wordpress.org/support/users/carl-alberto/)
 * (@carl-alberto)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364475)
 * Hi ragulin,
 * The quickest way to do an include of that library is thru your theme’s function.
   php, some suggested steps to do that:
    1) Copy the files [http://simplehtmldom.sourceforge.net/](http://simplehtmldom.sourceforge.net/)
   inside your theme’s folder eg simplehtmldom 2) Inside your theme’s function.php
   file, you can use this modified code to include that 3rd party library
 *     ```
       function foobar_func( $atts ){
       require_once('simplehtmldom/simple_html_dom.php');
       $html = file_get_html('http://hokejbal.cz/1-liga/tabulky/');
       $ret = $html->find('table.standings', 1);
       print $ret;
       }
       ```
   
 * 3) You can now call the foobar_func in any of your template files.
 * The best way to do this is creating a plugin (Google for it) so your custom code
   won’t be lost when you switch themes.
 *  Thread Starter [ragulin](https://wordpress.org/support/users/ragulin/)
 * (@ragulin)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364489)
 * Okay, my code in functions.php
 *     ```
       function foobar_func( $atts ){
       	require_once('ftp://skkelticz@ftpx.forpsi.com/www/wp-content/themes/sporty-child/simple_html_dom.php');
       	$html = file_get_html('http://hokejbal.cz/1-liga/tabulky/');
       	$ret = $html->find('table.standings', 1);
       	print $ret;
   
       }
       add_shortcode( 'foobar', 'foobar_func' );
       ```
   
 * And errors I get when I try to call the function via shortcode in my page
 *     ```
       Warning: require_once(): ftp:// wrapper is disabled in the server configuration by allow_url_include=0 in /web/htdocs2/skkelticz/home/www/wp-content/themes/sporty-child/functions.php on line 11
   
       Warning: require_once(ftp://...@ftpx.forpsi.com/www/wp-content/themes/sporty-child/simple_html_dom.php): failed to open stream: no suitable wrapper could be found in /web/htdocs2/skkelticz/home/www/wp-content/themes/sporty-child/functions.php on line 11
   
       Fatal error: require_once(): Failed opening required 'ftp://...@ftpx.forpsi.com/www/wp-content/themes/sporty-child/simple_html_dom.php' (include_path='.') in /web/htdocs2/skkelticz/home/www/wp-content/themes/sporty-child/functions.php on line 11
       ```
   
    -  This reply was modified 8 years, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
      Reason: put code in backticks
    -  This reply was modified 8 years, 9 months ago by [ragulin](https://wordpress.org/support/users/ragulin/).
 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364588)
 * Most servers (including yours) disable the ability to use URL wrappers ([ftp://](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/?output_format=md),
   [http://](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/?output_format=md),
   etc) in the _include()_ and _require()_ statements.
 * I’d suggest putting your “simplehtmldom” directory in the WordPress root, where
   wp-config.php is located. You can then include your file in WordPress with the
   following line:
 * `require_once(ABSPATH . 'simplehtmldom/simple_html_dom.php');`

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

The topic ‘acessing PHP library in functions.php’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 6 replies
 * 4 participants
 * Last reply from: [Dion](https://wordpress.org/support/users/diondesigns/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/acessing-php-library-in-functions-php/#post-9364588)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
