Comunitatea PHP Romania
 

 
{fetch}

{fetch}

{fetch} is used to retrieve files from the local file system, http, or ftp and display the contents.

  • If the file name begins with http://, the web site page will be fetched and displayed.

    Note: This will not support http redirects, be sure to include a trailing slash on your web page fetches where necessary.

  • If the file name begins with ftp://, the file will be downloaded from the ftp server and displayed.

  • For local files, either a full system file path must be given, or a path relative to the executed php script.

    Note: If template $security is enabled and you are fetching a file from the local file system, {fetch} will only allow files from within one of the defined secure directories.

  • If the assign attribute is set, the output of the {fetch} function will be assigned to this template variable instead of being output to the template.

Attribute NameTypeRequiredDefaultDescription
filestringYesn/aThe file, http or ftp site to fetch
assignstringNon/aThe template variable the output will be assigned to

Example 8-8. {fetch} examples

{* include some javascript in your template *}
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}

{* embed some weather text in your template from another web site *}
{fetch file='http://www.myweather.com/68502/'}

{* fetch a news headline file via ftp *}
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
{* as above but with variables *}
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}

{* assign the fetched contents to a template variable *}
{fetch file='http://www.myweather.com/68502/' assign='weather'}
{if $weather ne ''}
  <div id="weather">{$weather}</div>
{/if}

See also {capture}, {eval}, {assign} and fetch().

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Credit Card Consolidation | Website Design | Photo Gallery | Mortgage Calculator | Keeping Aquarium Fish
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis