我正在尝试在linux命令行执行php代码时使用php和html的问题
#php code.php
它运行正常,但如果我将PHP代码写入html
<html>
<body>
//php code
</body>
</html>
然后在浏览器中运行php代码显示为未执行的文本
答案 0 :(得分:0)
你应该用php标签编写代码,即<html>
<body>
<?php //php code here ?>
</body>
</html>
package com.mimoh.kulkarni.mimoh;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.Button;
import android.support.v7.widget.Toolbar;
public class homepage extends AppCompatActivity implements View.OnClickListener{
Button simpleq,toughq,seeapp,rateapp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homepage);
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
// getSupportActionBar().setCustomView(R.layout.homepage_titlebar);
simpleq = (Button)findViewById(R.id.simplequestions);
toughq = (Button)findViewById(R.id.toughquestion);
seeapp = (Button)findViewById(R.id.seemyotherapp);
rateapp = (Button)findViewById(R.id.rateapp);
simpleq.setOnClickListener(this);
toughq.setOnClickListener(this);
seeapp.setOnClickListener(this);
rateapp.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mymenu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.simplequestions:
Intent i = new Intent(homepage.this,simple_questions.class);
startActivity(i);
break;
case R.id.toughquestion:
Intent j = new Intent(this,tough_questions.class);
startActivity(j);
break;
case R.id.seemyotherapp:
// Intent k = new Intent(this,simple_questions.class);
//startActivity(k);
break;
case R.id.rateapp:
try {
Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent l = new Intent(Intent.ACTION_VIEW, uri);
startActivity(l);
}catch (ActivityNotFoundException n){
Uri uri = Uri.parse("http://play.google.com/store/apps/details?id="+getPackageName());
Intent l = new Intent(Intent.ACTION_VIEW,uri);
startActivity(l);
}
break;
}
}
}
您可以关注PHP Syntax