我有2个与主代码的合同,1个例如是'13'并且被放置在文件夹'13'中而另一个具有例如'00000013'(具有前导零)并且被放置在文件夹'00000013'中。但是如果我们读取主代码,我们会丢失前导零,以便我们看到错误的文档。如何从正确的文件夹中读取包含主代码“00000013”的文档?
if (isset($_GET['companycode']) && isset($_GET['mastercode'])) {
$FileRetreiverType = FileRetreiverTypeEnums::Tables;
$Code = $_GET['companycode'];
$Code2 = $_GET['mastercode'];
$Year = $_GET['year'];
$retreiver = new FileRetreiver($Year, $FileRetreiverType, $Code, $Code2);
$response .= $retreiver->GetResponse($ReturnFormat);
}
class FileRetreiver {
public function __construct($year, $retreiverType, $id, $id2 = '') {
$this->FileRetreiverType = $retreiverType;
$this->Id = $id;
$this->Id2 = $id2;
$this->Year = $year;
}
/* ... */
}
互联网上的文件夹按以下方式构建: 例如,您有一个文件夹:../2017/Tables/321/13/ 和一个文件夹:../ 2017 / Tables / 321/00000013 /
$Response = "../". $this->Year. "/ Tables /". $this->Id. "/". $this->Id2. "/";
答案 0 :(得分:0)
尝试这不会将其转换为int数据类型
if (isset ($_GET ['company code']) && isset ($_GET ['master code']))
{
$FileRetreiverType = FileRetreiverTypeEnums :: Tables;
$Code = "$_GET ['company code']";
$Code2 = (string)"$_GET ['master code']";
$Year = $_GET ['year'];
$retreiver = new FileRetreiver ($Year, $FileRetreiverType, $Code, $Code2);
$response. = $retreiver-> GetResponse ($ReturnFormat);
}