小编Joh*_*nde的帖子

使用file_get_contents获取类标记

我正在研究我的PHP脚本来解析html网页.我正在使用file_get_contents打开网址来获取内容列表.

这是代码:

$links = $row['links'];
$result = file_get_contents($links);
$html_content = str_replace("<a id='rowTitle1' class", "<a id='rowTitle1' class",$result);
print $html_content;
Run Code Online (Sandbox Code Playgroud)

这是html输出:

<li class="zc-ssl-pg" id="row1-1" style="">
<span id="row1Time" class="zc-ssl-pg-time">6:00 PM</span>
<a id="rowTitle1" class="zc-ssl-pg-title" href='http://www.mysite.com'>The Middle</a>
<a class="zc-ssl-pg-ep" href='http://www.mysite.com'>"Thanksgiving IV"</a>
Run Code Online (Sandbox Code Playgroud)

你能告诉我如何使用file_get_contents从row1-1类中的row1Time,rowTitle1和zc-ssl-pg-ep标签中获取值吗?

html php regex html-parsing

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

如何在PHP中获得自0年以来的天数?

它相当于MySQL to_days()函数.

是否有内置PHP函数可以执行此操作,还是需要将某些内容拼凑在一起?

php date date-math

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

使用$ _SESSION的PHP条件语句赋值,但为什么呢?

我实际上已经找到了如何自己解决这个特殊问题,但它仍然让我发疯,想知道为什么问题才会开始.我有条件声明:

if($_SESSION['authenticated'] = 1) {
    DOSTUFF;
}
Run Code Online (Sandbox Code Playgroud)

现在在此if语句之前,我知道$_SESSION['authenticated']通过使用是空的print_r().但是,在执行此代码块之后,此条件语句将1分配给$_SESSION['authenticated'],这使得if语句无论如何都会评估为true!我发现使用办法解决isset(),但我仍然不知道为什么一个条件语句将一个值分配给摆在首位的变量时,它应该只计算该条件是否为真或假.

php session conditional

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

真实的情况不起作用

我在PHP函数中有一个像'nameabc'的字符串.我检查字符串的最后三个字符是否为'abc'它应该删除它并返回剩余的字符串.这是我的条件:

$name="nameabc";
$last_char=substr($name,-4);   //it returns the 'abc'
if($last_char == 'abc')   //this condition does not return true
$real_name=substr($name,0,-4);
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题.

php if-statement substring

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

如何防止textareas重叠

我有两个textareas

<textarea>Text area 1</textarea>
<textarea>Text area 2</textarea>
Run Code Online (Sandbox Code Playgroud)

我想把自己定位在彼此之上:

在此输入图像描述

但是我不想用<br>.

还有另一种方法可以在CSS中执行此操作吗?例如,弄乱textarea margindisplay属性?

谢谢.

html css

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

&lt;a href&gt;将链接附加到当前URL的末尾

因此,每当我将.html文件上传到我的网站并使用新网址标记时,该链接就会使用户将链接附加到当前网址的末尾。例如,如果我的网站是example.com,而index.html文件放在example.com/test中,而链接是google.com,则该链接会将我带到example.com/test/google.com。在这种情况下,如何使a href标签将我带到google.com。

谢谢!

html .htaccess

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

从php获得爆炸的价值

可以说我有一个由;分隔的字符串;

  $something = "dog;cat;horse;fish";
Run Code Online (Sandbox Code Playgroud)

我知道我可以轻松地将其爆炸并从爆炸数组中获取适当的值:

 $explode = explode(";",$something);
Run Code Online (Sandbox Code Playgroud)

$explode[1] 会是猫.

有没有办法可以在线进行此操作?我的意思是:

$favoritePet = explode(";",$something)[1];
Run Code Online (Sandbox Code Playgroud)

$favoritePet 等于猫

显然上面是错误的,但我希望这说明了我想要达到的目标,同时爆炸并获得价值.

php arrays explode

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

您的SQL语法有错误; 查看与您的MySQL服务器版本对应的手册,以便在'-db'附近使用正确的语法

我正在尝试删除RDS MySQL实例中的数据库,我收到以下错误.有人可以帮我解决这个问题

  [ec2-user@ip-10-10-1-14 ~]$ mysql -h wda2d.cmkridjjwpjp.ap-southeast-2.rds.amazonaws.com -u happy-p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 6241
  Server version: 5.6.19-log MySQL Community Server (GPL)

  Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.

  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. …
Run Code Online (Sandbox Code Playgroud)

mysql sql mysql-error-1064 sql-drop

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

PHP的数组结构

我在这里遇到阵列结构问题.

为什么这个阵列

$plans = array(
    'id'   => 'free', 
    'name' => 'Free', 
    'sums' => array(
        'usd' => 0,
    ),
    'id'   => 'trial', 
    'name' => 'Trial', 
    'sums' => array(
        'usd' => 0,
    ),
);
Run Code Online (Sandbox Code Playgroud)

只返回我(我的数组的最后一个结果):

Array
(
    [id] => trial
    [name] => Trial
    [sums] => Array
        (
            [usd] => 0
        )

)
Run Code Online (Sandbox Code Playgroud)

任何有关这方面的帮助将非常感激.

非常感谢.

php arrays

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

如何将日期解析为上个月的同一天?

如何在 PHP 中解析日期到上个月的同一天?

例子:

   input                 Output

2018-07-25     ->       2018-06-25
2018-07-31     ->       2018-06-30 (because there is no 31)
Run Code Online (Sandbox Code Playgroud)

我的代码

$d = "2018-07-25";
$xd = date_parse_from_format("y-m-d", $d last month);
$output_d = date_create($xd)->format('Y-m-d');
Run Code Online (Sandbox Code Playgroud)

php datetime date-math

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