小编Jam*_*nes的帖子

访问类变量

这是我第一次使用OOP和PHP 5 ..所以这是我的问题..

我有一个文件disp.php,其中包含一个名为class disp的类(MVC中的模型)

<?php
class disp{
public $n_pages;
public $current_page;
private $cmd2;

/***************SQL command generator*******************/
private function getCmd2($cmd1,$id,$first_entry,$perpage,$tri){
    $cmd2=str_replace('COUNT(*)','*',$cmd1);
    $cmd2=$cmd2.' ORDER BY '.$id.' '.$tri.' LIMIT '.$first_entry.','.$perpage;
    return $cmd2;
}


/********************Items display******************/
function dispItems($cmd1,$id,$perpage,$tri){
  require('global/connection.inc.php');
  try{

     foreach($pdo->query($cmd1)as $r){
       $n_pages=ceil($r[0]/$perpage);
           if (isset ($_GET['pg'])){
          $current_page=intval($_GET['pg']);
               if ($current_page>$n_pages){
                    $current_page=$n_pages;
               }
               if ($current_page<=0){
                   $current_page=1;
               }
           }
           else{
           $current_page=1;
           $_GET['pg']=1;
           }
    }


    $i=1;
    $first_entry=($current_page-1)*$perpage;

    $objet=new disp();
     $cmd2=$objet->getCmd2($cmd1,$id,$first_entry,$perpage,$tri);

    $data=array();
    $i=0;
    foreach($pdo->query($cmd2) as $r){
    $data[$i]=$r;
    $i++;
    }

  return $data;
  }catch(PDOException $e){}
}
}
Run Code Online (Sandbox Code Playgroud)

这是文件 …

php oop variables class

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

安卓。Espresso:android.content.res.Resources$NotFoundException:字符串资源 ID

Android Studio 3.1。,Java 1.8。,摇篮4.4。

这是我的浓缩咖啡测试:

@RunWith(AndroidJUnit4.class)
public class SignInActivityTest {
    private Context context;

    @Rule
    public ActivityTestRule<SignInActivity> mActivityRule = new ActivityTestRule<>(SignInActivity.class, true, false);
    private MockWebServer server;

    @Before
    public void init() throws IOException {
        context = getInstrumentation().getContext();
        Intent intent = new Intent();
        mActivityRule.launchActivity(intent);    
    }

    @Test
    public void loginTextViewText() {
        String loginString = context.getResources().getString(R.string.login).toUpperCase();
        onView(withId(R.id.loginTextView)).check(matches(withText(loginString)));
    }


}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试开始测试时loginTextViewText()出现错误:

android.content.res.Resources$NotFoundException:字符串资源 ID

0x7f0e004f

在 android.content.res.Resources.getText(Resources.java:312) 在 android.content.res.Resources.getString(Resources.java:400) 在 com.myproject.android.activity.SignInActivityTest.loginTextViewText(SignInActivityTest.java :106)在java.lang.reflect.Method.invoke(本机方法)在org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)在org.junit.internal.runners.model.ReflectiveCallable。运行(ReflectiveCallable.java:12)

我该如何解决这个问题?谢谢。

android-espresso

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

如何将输入类型=“提交”替换为联系表 7 上的按钮?

我已经尝试过,但没有用。

remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit', 20 );<br>
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit_button' );

function wpcf7_add_shortcode_submit_button() {
    wpcf7_add_shortcode( 'submit', 'wpcf7_submit_button_shortcode_handler' );
}

function wpcf7_submit_button_shortcode_handler( $tag ) {
    $tag = new WPCF7_Shortcode( $tag );

    $class = wpcf7_form_controls_class( $tag->type );

    $atts = array();

    $atts['class'] = $tag->get_class_option( $class );
    $atts['id'] = $tag->get_id_option();
    $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );

    $value = isset( $tag->values[0] ) ? $tag->values[0] : '';
    if ( empty( $value ) )
        $value = __( 'Send', 'contact-form-7' );

    $atts['type'] = 'submit';

    $atts = wpcf7_format`enter code …
Run Code Online (Sandbox Code Playgroud)

php wordpress

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

如何在子主题中覆盖联系表单7 js文件

我在我的 WordPress 网站中使用联系表单 7 插件。我遇到一种情况,我必须修改并添加新的 JavaScript 代码来扩展功能。现在我想覆盖我的子主题中的文件script.js。文件位置:plugins/contact-form-7/includes/js/scripts.js

请帮忙。

javascript php wordpress wordpress-theming contact-form-7

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

编译时打字稿初始化错误

在IntelliJ-Idea 2017.1.1 IDE中获取TypeScript错误

我尝试过Enabled JavaScript,NodeJS和TypeScript Compiler.

我已经尝试了一切,但没有得到修复,我可能会遗漏某个地方.

错误:初始化错误(打字稿).无法读取未定义的属性'createHash

任何人都可以帮我解决?

在此输入图像描述

在此输入图像描述

的package.json

{
  "name": "TempPractice",
  "version": "0.0.1",
  "description": "First Angular App",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git@github.com:angularjs-de/angularjs-typescript-seed.git"
  },
  "main": "app/app.ts",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install",
    "update-deps": "npm update",
    "postupdate-deps": "bower update",
    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app",
    "pretest": "npm install",
    "test": "karma start karma.conf.js",
    "test-single-run": "karma start karma.conf.js --single-run",
    "preupdate-webdriver": "npm install",
    "update-webdriver": "webdriver-manager update",
    "preprotractor": …
Run Code Online (Sandbox Code Playgroud)

json intellij-idea angularjs typescript package.json

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

Symfony FromEvents 1 参数必须是

这里的错误不是明确的,从我认为它只是与参数之间的类型差异有关,但我还没有找到解决这个问题的方法......EventListener正在接收 2 个参数,但它没有提供哪个参数的信息它们是该问题的“1”参数,但我认为它是第二个,因为错误表示UserBundle\Form\FormEvent的单数实例,第一个参数是FormEvents复数类中的通用事件。

错误显示:

类型错误:传递给 UserBundle\Form\UserType::UserBundle\Form{closure}() 的参数 1 必须是 UserBundle\Form\FormEvent 的一个实例,Symfony\Component\Form\FormEvent 的实例给定

<?php

namespace UserBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\FormEvents;
class UserType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
        ->add('username',HiddenType::class)
        ->add('firstname',TextType::class)
        ->add('lastname',TextType::class)
        ->add('email', RepeatedType::class, 
            array('type' => EmailType::class, 'invalid_message' => 'The email fields must match.','options' 
                => array('attr' => array('class' => …
Run Code Online (Sandbox Code Playgroud)

php symfony

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

如何在测试用例中间重新启动 RobotFramework 中的变量值

我在资源文件中定义了一些变量。

*** Variables *** 
${x}       SomeValue
# Derived String
${y}       SomeString_${x}
Run Code Online (Sandbox Code Playgroud)

在现有测试用例中使用它后,我修改了${x}. 之后我可以${x}用作修改后的变量但${y}保持不变。我们是否有一些方法可以${y}根据 new重新启动${x}

robotframework

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

将对象数组转换为JSON

我有一个对象数组

[{"a":{"name":"abc","age":2}},
{"b":{"name":"xyz","age":3}},
{"c":{"name":"pqr","age":4}}]
Run Code Online (Sandbox Code Playgroud)

我需要将其转换为

[{"name":"abc","age":2},
{"name":"xyz","age":3},
{"name":"pqr","age":4}] 
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6

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