对于继承块的 2 个子模板文件,{{ block.super }}未解析
Python 2.5.2、Django 1.0、Windows XP SP3
所涉及文件的示例框架代码:
base.htmlitem_base.htmlshow_info_for_all_items.htmlshow_info_for_single_item.html文件 : base.html
{% block content %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
文件 : item_base.html
{% extends "base.html" %}
{% block item_info %}
Item : {{ item.name }}<br/>
Price : {{ item.price }}<br/>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
文件 : show_info_for_all_items.html
{% extends "item_base.html" %}
{% block content %}
<h1>info on all items</h1>
<hr/>
{% for item in items %}
{% block item_info %}
{{ block.super }} …Run Code Online (Sandbox Code Playgroud) 我有我的 index.php 页面,只是在我的标题之后我想要include一个 message.php 文件。这个 message.php 文件执行一些 mysql 查询,运行几个函数,最后echo生成一些文本。
如果我访问 mysite.com/message.php - 我可以在浏览器中看到我需要的所有文本。但是,如果我添加以下行:
<?php include "message.php"; ?>
Run Code Online (Sandbox Code Playgroud)
到我的 index.php,页面只加载到include语句,然后产生 500 内部服务器错误。这怎么可能呢?我完全被困在这里...
编辑:我已经想通了,感谢您使用 apache 日志为我指出正确的方向。即使我没有日志访问权限,我也使用 statement 对 .htaccess 进行了编辑php_value error_log log.txt。它将错误转储到同一目录中的 txt 文件中。该错误是由一个名称已被使用的函数产生的。这就是为什么单独的环境不会产生错误的原因。
在过去的 64 分钟里,这个错误耗尽了我的理性思考能力,我真的不知道我该怎么办。
当我在包含的文件中使用以下 3 行时:
var_dump(file_exists('G:/xampp/htdocs/myproject/public_html/includes/htmlPurifierAndMarkdown.php')); //retuurns true
var_dump(__FILE__);
include '../htmlPurifierAndMarkdown.php'; //gives error
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
boolean true
string 'G:\xampp\htdocs\myproject\public_html\includes\classes\genral.class.php' (length=71)
( ! ) Warning: include(../htmlPurifierAndMarkdown.php) [function.include]: failed to open stream: No such file or directory in G:\xampp\htdocs\myproject\public_html\includes\classes\genral.class.php on line 4
Call Stack
# Time Memory Function Location
1 0.0005 345328 {main}( ) ..\add.php:0
2 0.0036 382408 include( 'G:\xampp\htdocs\myproject\public_html\includes\classes\events.class.php' ) ..\add.php:28
3 0.0041 398024 include( 'G:\xampp\htdocs\myproject\public_html\includes\classes\standardpost.class.php' ) ..\events.class.php:2
4 0.0047 413928 include( 'G:\xampp\htdocs\myproject\public_html\includes\classes\genral.class.php' ) ..\standardpost.class.php:2
Run Code Online (Sandbox Code Playgroud)
简而言之:
所以我只是在想象东西还是这是一些严重的 php …
#include <iostream>
#include <string>
#include <sstream>
//#include <bits/stdc++.h>
#include <iomanip> // std::setprecision
#include <math.h>
using namespace std;
Run Code Online (Sandbox Code Playgroud)
我想删除标题#include <bits/stdc++.h>,因为它显着减慢了我的编译时间.
当我删除它时,我收到以下错误:
error: cannot convert ‘long double*’ to ‘double*’ for argument ‘2’ to ‘double modf(double, double*)’
fractpart = modf(val, &intpart);
Run Code Online (Sandbox Code Playgroud)
我认为问题是缺少头文件,但不知道它是哪一个.
我得到错误的代码是:
fractpart = modf(val, &intpart);
if (fractpart != 0) {
throw Error("ERR");
}
Run Code Online (Sandbox Code Playgroud) 我有一个片段布局,我想动态添加另一个子布局,
子布局xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:hint="Question"
android:textColor="@color/colorTextBlack"
android:textSize="16dp" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的主要布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2f2f2"
android:orientation="vertical">
<FrameLayout
android:id="@+id/flContainer"
android:layout_width="match_parent"
android:layout_margin="20dp"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在我的片段中我包含了子布局
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_start_question, container, false);
flContainer = (FrameLayout) v.findViewById(R.id.flContainer);
flContainer.addView(R.layout.sub_layout);
return v;
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助找到错误
假设我有两个班机场和飞机:
public class Airport
{
public static void main(String args[])
{
Airplane a1 = new Airplane();
}
}
public class Airplane
{
int seats;
public Airplane()
{
seats = 10;
}
}
Run Code Online (Sandbox Code Playgroud)
我想将这些类放在单独的JAR文件中,以便将来可以相互独立地开发它们,以防出现任何问题.由于Airport调用Airplane我必须Airplane在Airport源文件中导入.我想在项目中导入它们,我将用它来调用这些类.但即使我在项目中导入它们,仍然存在解决问题.
更新:你能举一个例子.classpath来完成这个调用层次结构吗?我只是将JAR添加到主项目的.classpath中,但Airport抱怨它无法找到方法Airplane.
这个问题显然是例如代码.很多时候,在展示std::stringstream示例时,我认为我需要明确添加#include <string>.
当我尝试跑步时
我收到此错误:
main.cpp:1:18:致命错误:temp.h:没有此类文件或目录#include“ temp.h”编译终止。
但是,Intellisense会检测到此标头存在。
Ctrl +左键单击main.cpp中的#include“ temp.h”成功将我带到该文件,并且该代码行在其下面没有任何弯曲的行。
我为.cpp文件和头文件有两个单独的文件夹,并在c_cpp_properties.json中配置了includePath,如下所示: 
我的工作区文件夹是temp,“ $ {workspaceFolder} / **”行应递归地检查子文件夹中的标题。我将绝对路径添加到头文件没有成功。
在这里,我有一个示例项目,其中包含两个源文件和一个头文件,如下所示:
main.c:
#include<stdio.h>
#include "personal.h"
int main(){
i = 5;
printf("Value is %d\n",i);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
sub.c:
#include "personal.h"
// do nothing
Run Code Online (Sandbox Code Playgroud)
最后是personal.h:
#pragma once
int i;
Run Code Online (Sandbox Code Playgroud)
每个.c文件都包含personal.h,后者受“保护”。我用gcc编译,一切正常:
>gcc sub.c main.c -o out
>./out
Value is 5
Run Code Online (Sandbox Code Playgroud)
但是对于g ++,会发生这种情况:
>g++ sub.c main.c -o out
/tmp/cctYwVnO.o:(.bss+0x0): multiple definition of `i'
/tmp/ccPElZ27.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
在文件链接方式,预处理器活动等方面,C ++和C之间在本质上有什么不同吗?我对其他编译器(如clang)尝试了相同的操作,并且发生了相同的情况。我也许在这里想念一些愚蠢的东西。
include ×10
c++ ×4
php ×3
android ×1
c ×1
compilation ×1
django ×1
file ×1
fragment ×1
header-files ×1
html ×1
import ×1
intellisense ×1
jar ×1
java ×1
path ×1
preprocessor ×1
string ×1