dimanche 29 mars 2015

PHP error "Call to undefined function" using simple html dom


Vote count:

0




I'm fairly new to PHP, and i have a problem in defining a function that returns an array containing a price and description strings.


I am using the "simple html dom" php files that facilitates parsing.


The function i create requires 2 arguments : the link (from which it will grab data) and the id (used to get the proper css syntax).




This is the get_product_details.php



<?
require_once 'simple_html_dom.php';
$priceMatchTable=('span[id=our_price_display]');
$descMatchTable=('div[id=short_description_content]');

function get_prod_details( $link , $id ) {

global $priceMatchTable, $descMatchTable;
$html = file_get_html($link);

$result['price'] = $html->find($priceMatchTable[$id],0);
$result['desc'] = $html->find($descMatchTable[$id],0);

return $result;
}




And this is the main php:



<?php
include 'get_product_details.php';

$link = 'http://ift.tt/1a75nXY';
$id = 0;

$result = get_prod_details($link, $id);
echo $result['price'];



?>




Finally i get an error which tell:



find($priceMatchTable[$id],0); $result['desc'] = $html->find($descMatchTable[$id],0); return $result; }
Fatal error: Call to undefined function get_prod_details() in C:\xampp\htdocs\dom\index.php on line 8


Best regards!



asked 31 secs ago







PHP error "Call to undefined function" using simple html dom

Aucun commentaire:

Enregistrer un commentaire