file - Require/Include in php -


i need help, have 2 php files , when calling functions tells me

fatal error: call undefined function get_contents() in /home/f77inq/public_html/php/shares.php on line 13

eventhough in files call functions have typed require("name ofmy file");

shares.php

<!doctype html public '-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd'>  <html xmlns='http://www.w3.org/1999/xhtml'>  <head>  <meta http-equiv='content-type' content='text/html; charset=utf-8' />  <title>shares</title>  <link rel='stylesheet' type='text/css' href='style.css' />  </head>   <body>  adad <?php      $data = get_contents();     print_contents($data); ?> </body>   </html>  

this file calling functions.

    <?php  require("../../php_include/services.php"); require("../../php_include/query.php");   putenv("oracle_home=/oracle/product/12.1.0/dbhome_1");   function get_contents() {      $conn = db_connect();     $shares = get_share($conn);     db_disconnect($conn);     $contents = array('shares' => $shares);     return $contents; }   function print_contents($contents) {     ?>         <table>             <tr>                 <th>company name</th>                 <th>rate</th>              </tr>     <?php     foreach ($contents['shares'] $share) {         print "<tr>";      //****** links every         $identifier = urlencode($share['company']);         print "<td><a href='share-details.php?company={$identifier}'>{$share['company']}</a></td>";          print "<td>{$share['rate']}</td>";          print "</tr>";     }     ?>         </table>     <?php } require ("shares.php");            //<<<<<<<<<<<<<<<<<<<<<< ?> 

as can see down bellow require shares php file.

both files located in same folder

for testing put code in file named like.php-

<?php function get_contents() {         echo "got it"; } require ("shares.php"); ?> 

and in shares.php file used this-

<!doctype html public '-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd'>  <html xmlns='http://www.w3.org/1999/xhtml'>  <head>  <meta http-equiv='content-type' content='text/html; charset=utf-8' />  <title>shares</title>  <link rel='stylesheet' type='text/css' href='style.css' />  </head>   <body>  <?php      $data = get_contents();      echo $data; ?> </body>   </html> 

it works without eny error.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -