Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial $_POST无法接收由smarty模版自动生成的二维数组

$_POST无法接收由smarty模版自动生成的二维数组

Jun 23, 2016 pm 02:03 PM

在同一个页面有多条相同的数据,分为组。

现在我遇到一个问题。
我无法取得smaryt对input自动生成的name序列。
其中,索引0和1是由smarty通过变量生成的。





我现在$_POST无法取得这些值,为什么?
var_dump($_POST[my]);

array (size=2)
  0 => string 'Array' 
  1 => string Array'

请大家帮忙。


回复讨论(解决方案)

BUG?
你 print_r($_POST['my']); 能看到什么?

BUG?
你 print_r($_POST['my']); 能看到什么?
什么也没有

BUG?
你 print_r($_POST['my']); 能看到什么?
我用一个全新的页面,对照PHP的手册做没问题,
但在正式开发的程序里却得不到。

无聊的吧?
既然你
var_dump($_POST[my]);
显示
array (size=2)
  0 => string 'Array' 
  1 => string Array'

那么
print_r($_POST['my']); 
怎么会什么也没有呢?

你标签闭合了吗

=>

无聊的吧?
既然你
var_dump($_POST[my]);
显示
array (size=2)
  0 => string 'Array' 
  1 => string Array'

那么
print_r($_POST['my']); 
怎么会什么也没有呢?

print_r($_POST['my'])
输出的也是
Array ( [0] => Array [1] => Array ) 

你标签闭合了吗

=>

当然是闭合了的,呵呵。

是不是因为name必须要是一个字符串才行?

是不是因为name必须要是一个字符串才行?
那不是的。

这个问题怎么办啊。一步一步调,一维数组没问题,二维数组就有问题了。

你在浏览器“查看网页源代码”,对这部分都看到了什么

源代码是由smarty自动生成的。

      <tr>        <td class="lable" colspan="6"><p align="center">职位信息</p></td>      </tr>            <tr>        <td class="lable">职位名称</td>                <td colspan="5"><input type="text" name="job[0][jobname]" value="营销经理" />营销经理</td>      </tr>     <!-- <tr>        <td class="lable">行业类别</td>        <td> 44
Copy after login


这里看起来,是正常的。

           <tr>        <td class="lable">职位名称</td>                <td colspan="5"><input type="text" name="job[1][jobname]" value="销售总监" />销售总监</td>      </tr>
Copy after login


还有这段


是这里生成的。

那你在接收表单时还做了什么?
smarty 好像不替你做表单数据接收处理的

我在接收时就用的

$jobname = $_POST["job"];var_dump($jobname);
Copy after login

输出的结果是
array (size=2)
  0 => string 'Array' (length=5)
  1 => string 'Array' (length=5)
使用print_r
输出的是
Array ( [0] => Array [1] => Array ) 

那你把表单的目标改成这样 action=test.php
test.php 就这样
print_r($_POST);

看一下结果

问题查到了,是系统框架过滤有问题。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

Announcement of 2025 PHP Situation Survey

See all articles