小编Blu*_*lur的帖子

如何从php中的用户输入中删除http,https和斜杠

示例用户输入

http://domain.com/
http://domain.com/topic/
http://domain.com/topic/cars/
http://www.domain.com/topic/questions/
Run Code Online (Sandbox Code Playgroud)

我想要一个PHP函数来使输出像

domain.com
domain.com/topic/
domain.com/topic/cars/
www.domain.com/topic/questions/
Run Code Online (Sandbox Code Playgroud)

让我知道 :)

php function preg-replace

39
推荐指数
6
解决办法
4万
查看次数

jQuery自动上传文件

我想文件输入会自动上传我的图像而不输入任何提交按钮.

<form action="/upload/" method="post" enctype="multipart/form-data">
  <input type="hidden" name="user_id" value="47" />
  <input type="file" name="upload" />
</form>
Run Code Online (Sandbox Code Playgroud)

让我知道jQuery的技巧

javascript jquery

15
推荐指数
2
解决办法
1万
查看次数

如何保护机器人的电话号码

我希望在公共页面上显示的电话号码将受到保护.示例将电话号码字符转换为HTML实体,机器人无法以纯文本格式获取号码.让我知道这个伎俩.

php jquery

9
推荐指数
1
解决办法
5579
查看次数

如何在调整图像大小时填充白色背景

目前的背景是黑色的.如何将颜色改为白色?

    #assuming the mime type is correct
    switch ($imgtype) {
        case 'image/jpeg':
            $source = imagecreatefromjpeg($source_image);
            break;
        case 'image/gif':
            $source = imagecreatefromgif($source_image);
            break;
        case 'image/png':
            $source = imagecreatefrompng($source_image);
            break;
        default:
            die('Invalid image type.');
    }

    #Figure out the dimensions of the image and the dimensions of the desired thumbnail
    $src_w = imagesx($source);
    $src_h = imagesy($source);


    #Do some math to figure out which way we'll need to crop the image
    #to get it proportional to the new size, then crop or adjust as …
Run Code Online (Sandbox Code Playgroud)

php gd resize-image image-resizing

9
推荐指数
1
解决办法
3万
查看次数

如何在$ _GET上向侧边栏添加类

我有问题要把正确的课程提到我的侧边栏.

function sidebar_class($var) 
{
    if (isset($_GET['page']) == $var )
    echo ' class="selected"';
}
Run Code Online (Sandbox Code Playgroud)

我的网址看起来像

http://domain.com/index.php?go=users
http://domain.com/index.php?go=settings
http://domain.com/index.php?go=backup
Run Code Online (Sandbox Code Playgroud)

我的侧边栏

<ul>
 <li<?php sidebar_class('users'); ?>><a href='index.php?go=users'>Users</a></li>
 <li<?php sidebar_class('settings'); ?>><a href='index.php?go=settings'>Settings</a></li>
 <li<?php sidebar_class('backup'); ?>><a href='index.php?go=backup'>Backup</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

现在我所有的侧栏课都是<li class="selected">.怎么解决?

css php xhtml function

2
推荐指数
1
解决办法
155
查看次数

如何使用通配符取消设置$ _SESSION

示例我有100个表单字段.每个字段都有错误会话.当表单成功提交时,我想要取消设置任何单词开头的会话$_SESSION['submit_']

首先,我可以这样做

unset($_SESSION['submit_first_name'],
$_SESSION['submit_last_name'],
$_SESSION['submit_status'],
$_SESSION['submit_mobile'],
$_SESSION['submit_category']);
Run Code Online (Sandbox Code Playgroud)

但是太久了.

如果我喜欢

session_destroy();
Run Code Online (Sandbox Code Playgroud)

然后会杀死我的登录会话

可以取消设置会话单词开头[submit_']

让我知道 :)

php session

2
推荐指数
1
解决办法
379
查看次数

如何组合jQuery的功能

在我的输入 id='currency'

首先,我想要maskMoney的货币格式

$(function () {
    $("#currency").maskMoney();
})
Run Code Online (Sandbox Code Playgroud)

然后自动提交

$('#currency').change(function () {
    $(this).closest("form").submit();
});
Run Code Online (Sandbox Code Playgroud)

如何让它一起工作?

更新:代码

<?php
if($_POST) {
    print_r($_POST);
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://padmin.googlecode.com/svn-history/r21/trunk/scripts/jquery.maskMoney.0.2.js"></script>
<script>
    $(function() {
        $("#currency").change(function() {
            $(this).closest("form").submit();
        }).maskMoney();
    });
    </script>

<form action="" method="post">
  <input type="text" name="currency" id="currency" />
</form>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

2
推荐指数
1
解决办法
360
查看次数

在htaccess中有5行代码的魔力是什么?

我想知道,使用此代码 .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Run Code Online (Sandbox Code Playgroud)

可以通过像Wordpres这样的URL的查询字符串做很多事情.这取决于我们的编码还是......?这样做的秘诀是什么?

如果您有一个很好的消息来源与我分享,请告诉我.一体.

.htaccess mod-rewrite coding-style

0
推荐指数
1
解决办法
66
查看次数