小编J.K*_*J.K的帖子

PHP没有响应Angularjs请求

我有一个带有一些angularjs验证的Raw表单,

<form name = "sform" novalidate="true">
<table border="0">
    <tr>
        <td>
            First name:
        </td>
        <td>
            <input type="text" name="fname" ng-model="fname" placeholder="First Name" required="true" ng-pattern="/^[A-Za-z]*$/">
        </td>
        <td ng-show="sform.fname.$invalid && !sform.fname.$pristine"  class="help-block">wrong name </td>
    </tr>

    <tr>
        <td>
            Last Name:
        </td>
        <td>
            <input type="text" ng-model="lname" placeholder="last Name" required="true" ng-pattern="/^[A-Za-z]*$/">
        </td>
        <td ng-show= "sform.lname.$invalid && !sform.lname.$pristine"  class="help-block">wrong Last name </td>
    </tr>
    <tr>
        <td>
            Email:
        </td>
        <td>
            <input type="email" ng-model="email" placeholder="email" required="true">
        </td>
        <td ng-show="sform.email.$invalid && !sform.email.$pristine"  class="help-block">wrong Email </td>
    </tr>
    <tr>
        <td>
            <button type="submit" ng-disabled="sform.$invalid" ng-click …
Run Code Online (Sandbox Code Playgroud)

php angularjs

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

WordPress联系人表格7文本值更改

WordPress-联络表格7

我试图找出当有人在其中输入值时修改cf7字段值的过滤器。

当用户在文本字段中键入并提交数据时,

  1. 验证-我已经完成
  2. 如果输入无效,则不应转到“谢谢”页面-我已完成
  3. 用新数据替换文本字段-未完成

例如:1

add_filter( 'wpcf7_validate_text*', 'your_validation_filter_func_tel', 100, 2 );
function your_validation_filter_func_tel( $result, $tag ) {

    $Yourvalue = $_POST['your-number'];
    if ( strlen( $Yourvalue ) == 2 ) {
        $result->invalidate( 'your-number', "Please enter a valid number.  " . );
        // HERE I WANT TO REPLACE NEW DATA TO TEXT FIELD
        $result->data( 'your-number', '1002' );
    } else if ( strlen( $Yourvalue ) == 3 ) {
        $result->invalidate( 'your-number', "Please enter a valid name." . );
        // HERE I WANT …
Run Code Online (Sandbox Code Playgroud)

php wordpress contact-form-7

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

我可以从 try 和 catch 返回 false 而不是抛出异常吗

我有一种将联系信息保存到数据库的方法。在该方法中,如果成功保存,我想返回 true,如果没有成功保存,则返回 false。不过,我使用的是 try catch 块。我可以返回 false 而不是抛出异常吗?它的工作原理是这样的,但我只是想知道这是一个好的做法,因为它是针对大学作业的。谢谢

在我的contact_functions.php页面中:

function saveContactInfo($firstName, $lastName, $email, $subject, $message, $pdoConnection){
    //Get timestamp of current time and store it into a variable
    //This is so we can keep a record of the time a message was sent.
    $messageTime = time(); 

    try{
        $query ="INSERT INTO contact_info (firstName, lastName, email, subject, message, messageTime) VALUES (:firstName, :lastName, :email, :subject, :message, :messageTime)";
        $statement = $pdoConnection->prepare($query);
        //bind our values. they will all be srting parameters.
        $statement->bindValue(':firstName', $firstName, PDO::PARAM_STR); …
Run Code Online (Sandbox Code Playgroud)

php return try-catch

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

当$ _GET动作时PHP允许符号#

如何设置$_GET允许此符号#

示例:

$a = "NE-TH#1-8";

<a href="test.php?a=<?php echo $a; ?>"Test</a>
Run Code Online (Sandbox Code Playgroud)

当我尝试单击该链接并回显该变量时,它只会显示NE-TH.它应该是NE-TH#1-8

请帮忙

php anchor

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

具有可变索引的枚举

我不确定我的问题的正确措辞是什么,但我添加了一个enum(NP_PostTypeType)因为我需要知道我的初始枚举(NP_PostType)中每个项目的类型是什么.

我将当前的PostType存储在$postType一个方法中,现在在该方法中我需要提取每种类型的类型.

我尝试做的是:switch(NP_PostTypeType::$type),但这会产生:Fatal error: Access to undeclared static property: NP_PostTypeType::$type

这些是我的2个枚举:

abstract class NP_PostType extends BasicEnum {
    const Event = "event";
    const Job = "job";
    const Quote = "quote";
    const Status = "status";
    const Video = "video";
}

abstract class NP_PostTypeType extends BasicEnum {
    const Event = "type";
    const Job = "type";
    const Quote = "format";
    const Status = "format";
    const Video = "format";
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

php oop enums

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

标签 统计

php ×5

anchor ×1

angularjs ×1

contact-form-7 ×1

enums ×1

oop ×1

return ×1

try-catch ×1

wordpress ×1