Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 有人能帮我做些需要工作的事情吗?_Php_File_Require_Require Once - Fatal编程技术网

Php 有人能帮我做些需要工作的事情吗?

Php 有人能帮我做些需要工作的事情吗?,php,file,require,require-once,Php,File,Require,Require Once,我有两个php文件,一个是调用函数,另一个是实现函数 if(isset($_GET['share'])) { $conn = db_connect(); if($_GET["newSorting"] == 1) { $shares = get_shareSearch($conn, "company"); }

我有两个php文件,一个是调用函数,另一个是实现函数

       if(isset($_GET['share']))
        {
            $conn = db_connect();
            if($_GET["newSorting"] == 1)
            {

                 $shares = get_shareSearch($conn, "company");

            }

            if($_GET["newSorting"] == 2)
            {

                $shares = get_shareSearch($conn, "rate");

            }
            if($_GET["newSorting"] == 3)
            {

                 $shares = get_shareSearch($conn, "issue_date");

            }

            db_disconnect($conn);
            $contents = array('shares' => $shares);
            return $contents;
        }

        else
        {
            $conn = db_connect();
            $shares = get_share($conn);
            db_disconnect($conn);
            $contents = array('shares' => $shares);
            return $contents;
        }

    }

    function print_contents($contents) 
    {

        if(count($contents['shares']) == 0)
        {
            echo "<script type = 'text/javascript'>alert('Sorry but share is not found! Q_Q');</script>";

        }
        else
        {
        ?>    
            <table>
                <tr>
                    <th><a href="share-company-links.php?companySort=true">Company Name</a></th>
                    <th><a href="share-company-links.php?rateSort=true">Rate</a></th>
                    <th><a href="share-company-links.php?issueSort=true">Issue date</a></th>
                </tr>
        <?php

        foreach ($contents['shares'] as $share) 
        {
            print "<tr>";
            $identifier = urlencode($share['COMPANY']);
            print "<td><a href='share-details.php?company={$identifier}'>{$share['COMPANY']}</a></td>";
            print "<td>{$share['RATE']}</td>";

            $issue_date = $share['ISSUE_DATE'];
            $issue_date = $issue_date === NULL ? "&lt; not available &gt;" : $issue_date;
            print "<td>{$issue_date}</td>";
            print "</tr>";
        }
        ?>
            </table>
        <?php
        }
    }

    require_once("shares.php");

    ?>
在实现我调用的函数<;strong>require(“shares.php”)-shares.php是调用函数的文件

问题是,它没有看到函数,所以我检查了函数是否存在,没有,它们不存在((

请看这里

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> 
</head> 

<body> 
<?php

if (function_exists('get_contents')) 
{ 
    if(function_exists('print_contents'))
    {
        $data = get_contents();
        print_contents($data);
    }
}

else
{
    print("Not Found");
}
?>
</body> 
</html> 

分享
下面是函数的实现。
       if(isset($_GET['share']))
        {
            $conn = db_connect();
            if($_GET["newSorting"] == 1)
            {

                 $shares = get_shareSearch($conn, "company");

            }

            if($_GET["newSorting"] == 2)
            {

                $shares = get_shareSearch($conn, "rate");

            }
            if($_GET["newSorting"] == 3)
            {

                 $shares = get_shareSearch($conn, "issue_date");

            }

            db_disconnect($conn);
            $contents = array('shares' => $shares);
            return $contents;
        }

        else
        {
            $conn = db_connect();
            $shares = get_share($conn);
            db_disconnect($conn);
            $contents = array('shares' => $shares);
            return $contents;
        }

    }

    function print_contents($contents) 
    {

        if(count($contents['shares']) == 0)
        {
            echo "<script type = 'text/javascript'>alert('Sorry but share is not found! Q_Q');</script>";

        }
        else
        {
        ?>    
            <table>
                <tr>
                    <th><a href="share-company-links.php?companySort=true">Company Name</a></th>
                    <th><a href="share-company-links.php?rateSort=true">Rate</a></th>
                    <th><a href="share-company-links.php?issueSort=true">Issue date</a></th>
                </tr>
        <?php

        foreach ($contents['shares'] as $share) 
        {
            print "<tr>";
            $identifier = urlencode($share['COMPANY']);
            print "<td><a href='share-details.php?company={$identifier}'>{$share['COMPANY']}</a></td>";
            print "<td>{$share['RATE']}</td>";

            $issue_date = $share['ISSUE_DATE'];
            $issue_date = $issue_date === NULL ? "&lt; not available &gt;" : $issue_date;
            print "<td>{$issue_date}</td>";
            print "</tr>";
        }
        ?>
            </table>
        <?php
        }
    }

    require_once("shares.php");

    ?>
if(isset($\u GET['share']))
{
$conn=db_connect();
如果($_GET[“newSorting”]==1)
{
$shares=get_shareSearch($conn,“公司”);
}
如果($_GET[“newSorting”]==2)
{
$shares=get_shareSearch($conn,“rate”);
}
如果($_GET[“newSorting”]==3)
{
$shares=get_shareSearch($conn,“发行日期”);
}
db_断开连接($conn);
$contents=array('shares'=>$shares);
返回$contents;
}
其他的
{
$conn=db_connect();
$shares=get_shares($conn);
db_断开连接($conn);
$contents=array('shares'=>$shares);
返回$contents;
}
}
函数打印内容($contents)
{
如果(计数($contents['shares'])==0)
{
echo“警报('抱歉,未找到共享!Q_Q');
}
其他的
{
?>    

结果将是找不到

使用这些函数的文件(share.php)应该
需要另一个文件,而不是反过来。因此,在shares中

<body> 
<?php

require_once('thatotherfile.php');

if (function_exists('get_contents')) 
{ 
    if(function_exists('print_contents'))
    {
        $data = get_contents();
        print_contents($data);
    }
}


使用这些函数的文件(share.php)应该
需要另一个文件,而不是反过来

<body> 
<?php

require_once('thatotherfile.php');

if (function_exists('get_contents')) 
{ 
    if(function_exists('print_contents'))
    {
        $data = get_contents();
        print_contents($data);
    }
}


使用这些函数的文件(share.php)应该
需要另一个文件,而不是反过来

<body> 
<?php

require_once('thatotherfile.php');

if (function_exists('get_contents')) 
{ 
    if(function_exists('print_contents'))
    {
        $data = get_contents();
        print_contents($data);
    }
}


使用这些函数的文件(share.php)应该
需要另一个文件,而不是反过来

<body> 
<?php

require_once('thatotherfile.php');

if (function_exists('get_contents')) 
{ 
    if(function_exists('print_contents'))
    {
        $data = get_contents();
        print_contents($data);
    }
}

您可以在使用函数的文件上使用,
include(“otherfile.php”)
require(“otherfile.php”)
include\u once(“otherfile.php”)
require\u once(“otherfile.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> 
</head> 

<body> 
<?php
include_once("otherfile.php");
//the rest of the code...

分享
您可以在使用函数的文件上使用,
include(“otherfile.php”)
require(“otherfile.php”)
include\u once(“otherfile.php”)
require\u once(“otherfile.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> 
</head> 

<body> 
<?php
include_once("otherfile.php");
//the rest of the code...

分享
您可以在使用函数的文件上使用,
include(“otherfile.php”)
require(“otherfile.php”)
include\u once(“otherfile.php”)
require\u once(“otherfile.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> 
</head> 

<body> 
<?php
include_once("otherfile.php");
//the rest of the code...

分享
您可以在使用函数的文件上使用,
include(“otherfile.php”)
require(“otherfile.php”)
include\u once(“otherfile.php”)
require\u once(“otherfile.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> 
</head> 

<body> 
<?php
include_once("otherfile.php");
//the rest of the code...

分享

请注意,
require\u once
print
不是函数,因此它们不需要参数。@PHPglue从官方文档中我看到它们正在使用
()
请注意,
require_once
print
不是函数,因此它们不需要参数。@PHPglue从官方文档中我看到它们正在使用
()
请注意,
require_once
print
不是函数,因此它们不需要参数。@PHPglue从官方文档中我看到它们正在使用
()
请注意,
require_once
print
不是函数,因此它们不需要参数。@PHPglue从官方文档中我看到它们在参数周围使用
()
@PHPglue您的意思是
()
我认为-文件名是一个参数并且是必需的-但是当我选择使用它们时。@PHPglue你的意思是围绕它们的参数
()
,我认为-文件名是一个参数并且是必需的-但是当我选择使用它们时。@PHPglue你的意思是围绕它们的参数
()
我认为-文件名是一个参数并且是必需的-但是当我选择使用它们时。@PHPglue你的意思是围绕它们的参数的
()
,我认为-文件名是一个参数并且是必需的-但是当我选择使用它们时。