我希望在我的页面上以这种格式显示当前日期:22/02/2013 - 12:00(日/月/年 - 小时)
我使用strftime("%d/%b/%G - %R", time())但在页面上没有显示任何内容.如果我做
echo var_dump(strftime("%d/%b/%G - %R", time()))
Run Code Online (Sandbox Code Playgroud)
它显示bool(false).知道我做错了什么?
在我开始之前,我想再次提出这个问题而道歉,正如许多用户所做的那样,但通过我做过的研究,我对我发现的内容并不满意.我只希望在这里提出一些非常有用的东西.
由于md5或sha1被认为是不好的做法(即使使用salt ???),我也尝试创建此函数来哈希我的密码
$password = $_POST['password']; // lets say that my password is: my_sercretp@ssword123
function encrypt_the_password($password){
$salt = "lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit";
return hash('sha256', $salt.$password);// can use also different algorithm like sha512 or whirlpool
}
$hashed_password = encrypt_the_password($password);
Run Code Online (Sandbox Code Playgroud)
请注意,这个我在一个只有一个用户的个人网站上使用它,我.如果有多个用户,我会想出这样的事情:
$password = $_POST['password'];
function generate_salt() {
$salt = uniqid(md5("lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit".microtime()));
$salt = hash('sha256', $salt);// can use also different algorithm like sha512 or whirlpool
return $salt;
}
function encrypt_the_password($password,$salt){
return hash('sha256', $salt.$password);// can use also different algorithm like sha512 or whirlpool
}
$hashed_password = encrypt_the_password($password,generate_salt());
Run Code Online (Sandbox Code Playgroud)
这是否足够安全(在每种情况下)或这可以改善更多??? …
在开始之前我不得不说我最近开始学习CodeIgniter,所以如果我再次重复这个主题,我很抱歉.
在程序php我会做这样的事情
// the header.php
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="blah blah">
<title>My Site</title>
<link href="css/main.css" rel="stylesheet" media="screen">
<php? if($current_page == 'about.php'): ?>
<link href="css/secondary.css" rel="stylesheet" media="screen"> // or some embed styles (<stlye> ... </style>)
<?php endif; ?>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/main_script.js"></script>
<php? if($current_page == 'contact.php'): ?>
<script src="js/validation.js"></script>
<?php endif; ?>
</head>
<body>
// end of header.php
include('template/header.php');
<h1>Heading1</h1>
<p>Lorem Ipsum...</p>
include('template/footer.php');
//footer.php
//maybe some js and here
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所以我想在CI中做类似的事情.所有页面/视图都具有相同的主要样式或脚本,但在某些情况下,某些特定页面(如contact.php)可能包含,并且仅在这些页面中包含某些特定样式或脚本(如validation.js).
我发现这个视频展示了如何使用CI创建模板/布局库,但我不太确定如何应用此功能才能正常工作.
我有这个 Json 对象数组
"students": [{
"id": 1,
"first_name": "John",
"last_name": "Doe",
"age": "14",
}, {
"id": 2,
"first_name": "Victoria",
"last_name": "Secret",
"age": "9",
}, {
"id": 3,
"first_name": "Jim",
"last_name": "Morrison",
"age": "16",
}, {
"id": 4,
"first_name": "Jack",
"last_name": "Daniels",
"age": "7",
},
}]
Run Code Online (Sandbox Code Playgroud)
我想在我的显示他们index.html.erb 按年龄排序的DESC顺序。我已经完成了一半,我已经设法对它们进行了排序,但不是按确切的 DESC 顺序排序。这是我的循环
<% @classroom['students'].sort_by { |st| st['age'] }.each do |student| %>
Run Code Online (Sandbox Code Playgroud)
这是我想要的结果:
16, Jim, Morrison
14, John, Doe
9, Victoria, Secret
7, Jack, Daniels
Run Code Online (Sandbox Code Playgroud)
这是我得到的:
14, John, Doe
16, …Run Code Online (Sandbox Code Playgroud) 我使用 Sublime Text 3 作为文本编辑器。我看过一些培训视频,其中讲师无需键入即可自动提取 .php 文件顶行的命名空间。据我所知,这是 phpstorm 的内置功能,但我想知道这是否可用,是否也适用于 Sublime?
我认为这可能可以通过快捷键或安装软件包来完成?有谁知道如何做到这一点?
我想将图像设置为专辑的封面,我是通过在do-while循环中的无线电输入中选择它来实现的.我已经在图像表中放入了一个名为is_cover的字段,如果图像设置为封面则为1,否则为0.
<input type="radio" name="cover" value="<?php echo $row_images['image_id']; ?>" <?php if($row_images['is_cover'] == 1){ echo "checked=\"checked\""; } ?> />
Run Code Online (Sandbox Code Playgroud)
我的问题是如何执行更新查询,将所有图像is_cover字段设置为0,并且只有所选图像的值为1.
我想说的是我怎样才能做到这一点:
$is_cover = $_POST['cover'];
$query = "
UPDATE images
SET is_cover = 1
WHERE image_id = {$is_cover}
AND SET is_cover = 0
WHERE image_id <> {$is_cover}
";
Run Code Online (Sandbox Code Playgroud) 我遇到了问题,请给我一些帮助.我使用GD库制作了一个使用PHP创建图像的脚本,但问题是当我在Firefox上预览它时,它向我显示Firebug中的错误:"图像损坏或截断:localhost/my_scripts/images.php".注意:这不是PHP显示的错误,它似乎更像是来自浏览器的错误.
我已经多次检查了我的代码的语法,我也试过了其他的gd函数,比如imagegif,imagettftext等,但没有任何效果.这是我的代码:
//$image = @imagecreate(200, 20)or die("Cannot Initialize new GD image stream");
$image = imagecreate(200, 20);
$background = imagecolorallocate($image,0,0,0);
$foreground = imagecolorallocate($image,255,255,255);
imagestring($image,5,5,1,"This is a Test",$foreground);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
Run Code Online (Sandbox Code Playgroud)
GD库启用我已经在phpinfo()中检查过了,我也试过预览它并在Chrome上看起来一样.任何想法我可能做错了或为什么会这样?我该如何解决这个错误?
我的Album_Model内部具有此功能:
public function upload($album_id, $album){
$album= strtolower($album);
$upload_config = array(
'upload_path' => './uploads/'.$album,
'allowed_types' => 'jpg|jpeg|gif|png',
'max_size' => '2000',
'max_width' => '680',
'max_height' => '435',
);
$this->load->library('upload', $upload_config);
// create an album if not already exist in uploads dir
// wouldn't make more sence if this part is done if there are no errors and right before the upload ??
if (!is_dir('uploads')) {
mkdir('./uploads', 0777, true);
}
if (!is_dir('uploads/'.$album)) {
mkdir('./uploads/'.$album, 0777, true);
}
if (!$this->upload->do_upload('imgfile')) {
// upload failed …Run Code Online (Sandbox Code Playgroud) 我有一个 Laravel 5.5 项目并试图从我的终端运行这个命令
composer require laravel/cashier
Run Code Online (Sandbox Code Playgroud)
但我遇到了这个问题:
Problem 1
- stripe/stripe-php v3.9.2 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.9.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.9.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.8.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php …Run Code Online (Sandbox Code Playgroud) 我有一个新的 MacOS Catalina 10.15.6,我正在按照此链接中的步骤显示 git 分支名称在终端 macos 中cd,这样每当我在 git 存储库中时,我就可以在终端上显示分支名称。
我在我的主目录中,所以当我运行时ls -la,我看不到以下任何文件
.zshrc, .bashrc, .bash_profile, .zprofile
Run Code Online (Sandbox Code Playgroud)
列表中显示的唯一相关文件是.bash_history和.zsh_history。
这些是否位于不同的路径上,或者我是否错过了该过程中的任何步骤?
好吧,我糊涂了。
里面application/config.php在评论中说:
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All …Run Code Online (Sandbox Code Playgroud) 我有一系列这样的项目:
$data = array(
'item1' => array( // is even
'icon' => 'commenting',
'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. ',
),
'item2' => array(// is odd
'icon' => 'sticky-note',
'content' => 'Debitis id eligendi assumenda, cumque optio veniam eos perferendis molestias explicabo odit',
),
'item3' => array(// is even
'icon' => 'users',
'content' => 'Libero, suscipit, quos. Quae praesentium tempore minima quod tempora odio',
),
'item4' => array(// is odd
'icon' => 'thumbs-o-up',
'content' => 'Lorem …Run Code Online (Sandbox Code Playgroud) php ×9
codeigniter ×3
arrays ×1
bash ×1
broken-image ×1
composer-php ×1
file-upload ×1
gd ×1
hash ×1
image ×1
json ×1
laravel ×1
laravel-5.5 ×1
layout ×1
mysql ×1
namespaces ×1
package ×1
ruby ×1
security ×1
sorting ×1
sql-update ×1
strftime ×1
sublimetext3 ×1
templates ×1
terminal ×1
zsh ×1