小编Win*_*aga的帖子

ColdFusion CFTRY和CFCATCH混淆

我试图使用<cftry><cfcatch>代码块.但是我对某些事情感到困惑,我<cftry>在查询中放了一个块,并且该查询的结果不是空的,但条件总是进入<cfcatch>块.

示例:

<cftry>
  <cfquery name="qcar" datasource="xxxx">
     select * from allcar
   </cfquery>
<cfcatch>
   <script>
      alert("ERROR");
   </script>
</cfcacth>
</cftry>
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题<cfcatch>

coldfusion

5
推荐指数
2
解决办法
6932
查看次数

ColdFusion createdate()

我刚学习ColdFusion功能CreateDate.但是,当我使用CreateDate时,值输出是不同的.我的意思是它每个月和每天都在变化.

<cfoutput>
<cfset txtBirthDate='07-10-1983'>
<cfset valueOf_txtBirthDate =  dateFormat(CreateDate(Year(txtBirthDate),Month(txtBirthDate),Day(txtBirthDate)),'YYYY-MMM-DD')>

#txtBirthDate#<br/><br/>
#valueOf_txtBirthDate#<br/>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)

txtBirthDate1983年7月10日,但价值 valueOf_txtBirthDateCreateDate创建是1983年07月10.七月为什么?它应该是10月:07(日期),10(月),1983(年).

格式有问题吗?

coldfusion date

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

简单的html dom抓住h1标头

我刚刚学习了simple_html_dom.php,我尝试用一​​些类来获取h1内容.

<h1 class="entry-title">example for the header</h1>
Run Code Online (Sandbox Code Playgroud)

这里是我想要获取内容的网站的原始html文件.

    <header class="entry-header">
    <div class="entry-meta">
        <span class="cat-links"><a href="https://xxxxx/2016/08/11/xxxxxxx" rel="category tag">News</a></span>
    </div>
    <h1 class="entry-title">example for the header</h1>
    <div class="entry-meta">
        <span class="entry-date"><a href="https://xxxxx/2016/08/11/xxxxxxx" rel="bookmark"><time class="entry-date" datetime="2016-08-11T11:54:07+00:00">11 August 2016</time></a></span> 
        <span class="byline"><span class="author vcard"><a class="url fn n" href="https://xxxxx/2016/08/11/xxxxxxx" rel="author">wndwnrt</a></span></span>          
        <span class="comments-link"><a href="https://xxxxx/2016/08/11/xxxxxxx">1 Comment</a></span>
    </div>
</header>
Run Code Online (Sandbox Code Playgroud)

这里我的代码获取h1 class ="entry-title"内容(标题示例)

<?php
 require_once __DIR__.'/simple_html_dom.php';
 $html = new simple_html_dom();
 $html->load_file('https://xxxxx/2016/08/11/xxxxxxx');
 $header_1 = $html->find('h1[class="entry-title"]')->innertext;
?>
<table border="1">
 <thead>
   <tr>
     <th><?php echo $header_1; ?></th>
  </tr>
 </thead>
</table>
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,结果是错误:

Trying to get property of non-object …
Run Code Online (Sandbox Code Playgroud)

html php dom simple-html-dom

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

标签 统计

coldfusion ×2

date ×1

dom ×1

html ×1

php ×1

simple-html-dom ×1