我需要一个php函数,它从URL生成一个纯域名.因此http://,如果这些部分存在,则必须删除此函数,www并/从URL中删除(斜杠)部分.以下是输入和输出示例:输入 - > http://www.google.com/ | 输出 - > google.com
输入 - > http://google.com/ | 输出 - > google.com
输入 - > www.google.com/ | 输出 - > google.com
输入 - > google.com/ | 输出 - > google.com
输入 - > google.com | 输出 - > google.com
我检查了parse_url功能,但没有返回我需要的内容.因为,我是PHP的初学者,对我来说很难.如果您有任何想法,请回答.
Thanx提前.
我需要获取最近24小时内插入的记录.我已经阅读了它,并得到我需要DATETIME在我的MySQL日期列中使用类型.
但我的问题是我不知道如何DATETIME用PHP 生成MySQL 类型的日期 ?
我怎样才能做到这一点?提前致谢.
我需要在PHP中使用绑定参数在MySQLi PDO中执行这个mysql查询:
mysql_query("INSERT INTO `posts` (post_name,publish_date) VALUES ($post_name,NOW()) ")
Run Code Online (Sandbox Code Playgroud)
我使用这样的脚本,但它没有正确插入publish_date.
$publish_date = 'NOW()';
$insert = $mysqli->prepare("INSERT INTO posts (post_name,publish_date) VALUES (?,?)");
$insert->bind_param("ss", $post_name $publish_date);
$insert->execute();
Run Code Online (Sandbox Code Playgroud)
它将记录插入到publish_date列中,如下所示:0000-00-00 00:00:00
我该怎么做?提前致谢.
PS:日期列的类型是datatime.
首先,我需要检查URL字符串,如果URL的协议是https,那么我需要http在PHP中替换.所以这个php函数的输入和输出必须是这样的:
Input -> https://example.com/example/https.php
Output-> http://example.com/example/https.php
Input -> http://example.com/example/https.php
Output-> http://example.com/example/https.php
Run Code Online (Sandbox Code Playgroud) 我需要在PHP中获取重定向页面的URL.
假设我有一个URL http://example.com,当我打开它时,它重定向到http://redirected_url.com.所以这个PHP函数的输入和输出必须是这样的:
http://example.com http://redirected_url.com我怎样才能做到这一点?
编辑:我不是指重定向.我需要重定向页面的网址.所以我不知道重定向的网址,但我需要找到它.