我有2个字符串并替换它们,所以我只得到URI部分.
$base_url = 'http://localhost/project/';
$url = 'http://localhost/project/controller/action/param1/param2';
Run Code Online (Sandbox Code Playgroud)
我正在检查URI部分.
$only_segments = str_replace($base_url, '', $real_url);
Run Code Online (Sandbox Code Playgroud)
基本上我做: {url} - {base_url} = {only_segments}
然后我可以获得细分:
$parts = explode('/', $only_segments);
print_r($parts);
Run Code Online (Sandbox Code Playgroud)
题:
我是在正确的道路上还是使用$ _SERVER ['REQUEST_URI']可以更轻松地完成?
注意:我不想project
在URI部分,它是localhost的子文件夹.
我在包装div中提交了按钮.我有所有这些情况的全局设置,其中输入是这样的包装器.
我只想让一个人在包装器的中心,但是属性width:100%;
并且box-sizing: border-box;
是全宽的,所以我的text-align: center;
属性不起作用.我想禁用全宽到边距按钮到包装器的中心.
如何禁用width: 100%;
和box-sizing: border-box;
使用CSS?
因此我可以将输入集中到中心.
<div class="wrapperInput">
<input type="submit" class="submit" value="Submit">
</div>
Run Code Online (Sandbox Code Playgroud)
#wrapper .wrapperInput input {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Run Code Online (Sandbox Code Playgroud) 我使用函数 resizeImage() 来调整图像大小,但偶尔会失败。大多数时候它都可以工作,但有时我会收到此警告,提示它找不到文件。应该是什么问题呢?如何解决这个问题?
想法:
用法:
<?php
session_start();
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_DIR', realpath(dirname(__FILE__)) . DS);
$image = ROOT_DIR . 'cache' . DS . $_SESSION['file_name'];
resizeImage($image, 400, 400);
Run Code Online (Sandbox Code Playgroud)
抛出错误:
Warning: imagejpeg(C:\wamp\www\mvc\cache\temp_1385972631.jpg): failed to open stream: Invalid argument in C:\wamp\www\mvc\application\helpers\image_helper.php on line 95
Run Code Online (Sandbox Code Playgroud)
第 95 行:imagejpeg($newImage, $image, 100);
这是resizeImage()函数:
<?php
function resizeImage($image, $max_width, $max_height) {
$img = getimagesize($image);
$mime = $img['mime'];
$width = $img[0];
$height = $img[1];
if ($height > $width) {
$scale = …
Run Code Online (Sandbox Code Playgroud) 我想在步骤0.5中创建两个十进制数之间的随机数.
示例:0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5 ......
使用PHP生成两个小数之间的随机十进制
到目前为止,我可以使用一个十进制逗号生成0到5之间的数字.
如何整合步骤0.5?
$min = 0;
$max = 5;
$number = mt_rand ($min * 10, $max * 10) / 10;
Run Code Online (Sandbox Code Playgroud) 我有这样的页面链接:
import.html
<h1>Title</h1>
<img src="img/pic1.jpg" alt="" title="Picture 1" class="pic">
<img src="img/pic2.jpg" alt="" title="Picture 2" class="pic">
<img src="img/pic3.jpg" alt="" title="Picture 3" class="pic">
<p>random text</p>
<img src="img/pic4.jpg" alt="" title="Picture 4" class="pic">
Run Code Online (Sandbox Code Playgroud)
的index.php
<?php
//get file content
$html = file_get_contents('import.html');
function replace_img_src($img_tag) {
$doc = new DOMDocument();
$doc->loadHTML($img_tag);
$tags = $doc->getElementsByTagName('img');
if (count($tags) > 0) {
$tag = $tags->item(0);
$old_src = $tag->getAttribute('src');
$new_src_url = 'website.com/assets/'.$old_src;
$tag->setAttribute('src', $new_src_url);
return $doc->saveHTML($tag);
}
return false;
}
// usage
$new = replace_img_src($html);
print_r(htmlspecialchars($new));
Run Code Online (Sandbox Code Playgroud)
目标:
我想替换import.html文件中元素的 …
<?php
$val = '245E1';
var_dump($val); // return string(5) "245E1"
$n = is_numeric($val);
var_dump($n); // return bool(true)
Run Code Online (Sandbox Code Playgroud)
问题:is_numeric返回TRUE
问题:
如何将$ val视为字符串而不是数字?
如何禁用指数解释?
标题说我正在寻找一个PHP函数来检查你是否可以在你的服务器上使用.htaccess文件.
我应该测试什么?
选项1:
也许如果安装了mod_rewrite模块?
选项2:检查' httpd.conf '中是否显示" AllowOverride None " .
感谢您的建议,代码也会有所帮助;)
我有div分类1,2,3 ...作为HTML布局
HTML:
<div class="bigdiv">
<div class="div1">div 1</div>
<div class="div2">div 2</div>
<div class="div3">div 3</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.div1 {
float: left;
}
.div2 {
float: left;
}
.div3 {
float: left;
}
Run Code Online (Sandbox Code Playgroud)
如何使用CSS将div重新排序为此布局
<div class="bigdiv">
<div class="div3">div 3</div>
<br>
<div class="div1">div 1</div>
<div class="div2">div 2</div>
</div>
Run Code Online (Sandbox Code Playgroud)
通过CSS(float,:after,:before)
我的尝试:
.div3 {
float: right;
}
.div3:before {
content: '\A\A';
white-space: pre;
}
Run Code Online (Sandbox Code Playgroud)
先感谢您.
我正在编写一个脚本,我需要保存当前日期,以及从该日期起1个月的日期.我很确定该time()
变量有效,但我不知道该怎么做+1 month
?
任何想法,建议.干杯!
我有这样的 SCSS 样式,我想使用 SCSS 中的 @for 来更有效地编写它。
迄今为止:
@for $i from 1 through 6 {
h#{$i} {
$size: {$i} * 1.4;
@include font-size($size);
}
}
Run Code Online (Sandbox Code Playgroud)
注意:不介意计算尺寸,仅用于测试
但语法不对。
预期输出
h1 {
@include font-size(3.2);
}
h2 {
@include font-size(2.4);
}
h3 {
@include font-size(1.8);
}
h4 {
@include font-size(1.6);
}
h5 {
@include font-size(1.3);
}
h6 {
@include font-size(1.2);
}
Run Code Online (Sandbox Code Playgroud)