我的整个PHP页面只显示为文本,并且不执行任何PHP代码.这很奇怪,因为当我<? phpinfo(); ?>在test.php文件中测试它时,我得到了一个成功的测试,它可以在我的Apache服务器上运行.但是,当我尝试做任何其他事情时.它只显示为文本.
编辑:这是代码的链接.我无法弄清楚如何在这里发布.引擎收录
<?php
// create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find = $_POST['find'];
?>
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order processed at ".date('H:i, jS F Y')."</p>";
echo "<p>Your order is as follows: </p>";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "Items ordered: ".$totalqty."<br />";
if ($totalqty == 0) {
echo "You did …Run Code Online (Sandbox Code Playgroud) 我试图使用rand()函数来洗牌一副牌,但出于某种原因,当我试图看到洗牌的牌子看起来像是什么时,它完全没有洗牌.我不确定我错过了什么,所以任何帮助将不胜感激.
void Deck::Shuffle()
{
for (int j = 0; j <= 51; j++)
{
srand(time(0));
int i = 1 + rand()%52;
int k = 1 + rand()%52;
Card temp = theDeck[i];
theDeck[i] = theDeck[k];
theDeck[k]= temp;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:谢谢大家的帮助.我修复了现在读取的代码.
void Deck::Shuffle()
{
srand(time(0));
for (int j = 0; j <= 51; j++)
{
int i = 1 + rand()%52;
int k = 1 + rand()%52;
Card temp = theDeck[i];
theDeck[i] = theDeck[k];
theDeck[k]= temp;
}
}
Run Code Online (Sandbox Code Playgroud) 我试图从文件中读取客户的姓名,身份证和贷款信息.该文件设置如下:
Williams, Bill
567382910
380.86
Davidson, Chad
435435435
400.00
Run Code Online (Sandbox Code Playgroud)
基本上,每次我使用新名称时,信息都将被放入Customer类的新对象中.我的问题是,我正在尝试从文件中读取,但我不确定如何正确地重载操作符,只读取文件中的3行,并将它们放在正确的位置.
我在这里创建客户并打开文件:
Menu::Menu()
{
Customer C;
ifstream myFile;
myFile.open("customer.txt");
while (myFile.good())
{
myFile >> C;
custList.insertList(C);
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我在.cpp文件中的Menu类.以下是我的.cpp文件中Customer类的重载运算符的代码(我知道该怎么做).
istream& operator >> (istream& is, const Customer& cust)
{
}
Run Code Online (Sandbox Code Playgroud)
我不确定如何只获得三条线并将它们放入客户的各自位置:
string name
string id
float loanamount
Run Code Online (Sandbox Code Playgroud)
如果有人能帮我解决这个问题,我真的很感激.
我正在尝试使用getline解析文档以获取整行并将其放在名为"line"的字符串变量中.问题是我收到的错误是:"没有重载函数getline的实例与参数列表匹配." 任何人都可以帮我解决这个问题吗?
#include <iostream>
#include <fstream>
#include <string>
#include "recordsOffice.h"
using namespace std;
RecordsOffice::RecordsOffice()
{
}
void RecordsOffice::parseCommands (string commandsFileName)
{
//String to hold a line from the file
string line;
//Open the file
ifstream myFile;
myFile.open(commandsFileName);
// Check to make sure the file opened properly
if (!myFile.is_open())
{
cout << "There was an error opening " << commandsFileName << "." << endl;
return;
}
//Parse the document
while (getline(myFile, line, '/n'))
{
if (line[0] == 'A')
{
addStudent(line);
}
Run Code Online (Sandbox Code Playgroud) 我试图重载<<运算符,以便打印出一个学生对象:
Student: <name>,<number>,<email address>,<year>,<major>
Run Code Online (Sandbox Code Playgroud)
我在尝试编译程序时遇到错误:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion)
Run Code Online (Sandbox Code Playgroud)
我的实现文件中的函数如下所示:
ostream& operator<<(ostream& output, const Student& student)
{
output << "Student: " << student.name <<", " << student.m_Number <<", " << student.email <<", " << student.year << ", " << student.major << endl;
return output;
}
Run Code Online (Sandbox Code Playgroud)
我的这个类的头文件:
#include <iostream>
using namespace std;
class Student
{
public:
//Default constructor
Student();
//Set the student …Run Code Online (Sandbox Code Playgroud)