我用PHP得到了这个数组:
$arr =('1-1.jpg','1-2.jpg','11-3.jpg', '1-4.jpg', '3-5.jpg', '41-5.jpg','1-3.jpg','4-5.jpg','14-5.jpg','54-5.jpg','64-5.jpg','14-5.jpg', '1-5.jpg');
Run Code Online (Sandbox Code Playgroud)
我需要这个数组,但我在服务器上有PHP 5.27版本:(
$newarray=('1-1.jpg','1-2.jpg','1-3.jpg', '1-4.jpg', '1-5.jpg');
Run Code Online (Sandbox Code Playgroud)
忘记服务器版本,标准是"1-".如何获得仅以"1-"开头的所有元素?
可能重复:
PHP已发送的标头
在这里我有一个奇怪的问题来保护我的页面,检查会话是否开始,如果没有重定向登录,
<?php
require_once ('includes/config.inc.php');
// Start output buffering:
ob_start();
// Initialize a session:
session_start();
// Check for a $page_title value:
if (!isset($page_title)) {
$page_title = 'User Registration';
}
// If no first_name session variable exists, redirect the user:
if (!isset($_SESSION['first_name'])) {
$url = BASE_URL . 'index.php';
ob_end_clean(); // Delete the buffer.
header("Location: $url");
exit(); // Quit the script.
}
?>
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:第8行:
session_start()[function.session-start]:无法发送会话缓存限制器 - 已发送的标头
有人可以发布一个很好的解决方案来检查会话是否已启动,如果没有重定向到登录页面,那么留在页面上?Txanks
我有一个奇怪的问题,无法进入课堂$_POST,很奇怪,这里是问题和错误?课堂很简单,只是为了演示.
if(isset($_POST['name']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$komentar = new comments($name,$email,$comment);
$komentar->provera();
}
Run Code Online (Sandbox Code Playgroud)
类:
class comments
{
public function __construct($name, $email, $comment)
{
$this->name=$name;
$this->email=$email;
$this->comment=$comment;
}
public static function provera()
{
$poruka=$this->comment;
echo $poruka;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
Fatal error: Using $this when not in object context in
classes\comments.inc.php on line 12
Run Code Online (Sandbox Code Playgroud) 将字符串转换为对象时遇到问题.这是功能:
public function slikepoid($dire,$id)
{
$this->dire=$dire;
$this->id=$id;
$slike = $this->skupljanjeslika($this->dire);
$slikeid = array_filter($slike, function($el) {
return substr( $el, 0, 2) == '$this->id-'; // Here is the problem !
});
return $slikeid;
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
致命错误:在第8行的对象上下文中使用$ this
我试过了:
return substr( $el, 0, 2) == ''.(string)$this->id;'-';
Run Code Online (Sandbox Code Playgroud)
但没有运气:(
php ×4
array-filter ×1
arrays ×1
class ×1
function ×1
http-headers ×1
object ×1
session ×1
sorting ×1
string ×1