如何通过单击链接将$ _POST信息从一个页面传递到另一个页面?没有表单或提交框,只要最终用户点击链接,它就会在打开的链接中发布相关信息.
伪代码,但是:
//On first page
<a href="./page.php" onclick="post" value="var">Click me!</a>
...
//On the page the above links to
$variable = $_POST["var"];
Run Code Online (Sandbox Code Playgroud)
我考虑的是以下内容,虽然不是很漂亮,但仍有效.我喜欢它所以它是一个帖子,而不是一个得到.
//On first page
<a href="./page.php?var=<?php echo $variable; ?>">Click me!</a>
...
//On second page
$variable = $_GET["var"];
Run Code Online (Sandbox Code Playgroud) 我有一个循环,i通过字符串递增,我想打印该字符,但它的ASCII代码.
myString = "90210";
for (int i = 0; i < myString.length(); i++) {
System.out.println(myString.charAt(i));
}
Run Code Online (Sandbox Code Playgroud)
要输出:
57
48
50
49
48
Run Code Online (Sandbox Code Playgroud)
显然charAt()不会这样做,但我需要另一种方法来附加它以获得我想要的结果.
我有一个characterData带有构造函数的类:
class characterData() {
private:
int position[2];
vector<vector<int> > pixelData;
int num;
public:
characterData() {
num = -1;
}
void setValues(int p[2], vector<vector<int> > v, int n) {
position[0] = p[0];
position[1] = p[1];
pixelData = v;
num = n; // if setValues() is called, n will always > -1
}
};
Run Code Online (Sandbox Code Playgroud)
我这样做,所以characterData我的代码中可以有一个"空" .我的思维过程是,如果num == -1,setValues()没有被称为上characterData对象.
后来在我的代码中,我有一个characterData k只被初始化,setValues()没有被调用,所以k.num == -1.
最终我改变了值,k但希望将其"重置"为原始形式.
characterData …Run Code Online (Sandbox Code Playgroud) 我正在可视化Mandelbrot集以及其他一些分形,并且有很多重复的代码,但是没有代码重用。
我正在使用的功能之一如下:
/**
* determines whether a pixel lies in the set
* @params x, y - x and y coordinates on R/I axes
* @param c - a complex number
*/
void calculateSet(int x, int y, Complex c) {
Complex z = c.clone();
int n = 0;
for (; n < maxDepth; n++) {
if (z.dis() > 4) { break; }
z = z^2 + c;
}
// some code using n to color the set
}
Run Code Online (Sandbox Code Playgroud)
这遵循Mandelbrot集:
z_(n+1) …Run Code Online (Sandbox Code Playgroud) #include <vector>
class M {
public:
M(unsigned int);
unsigned int n;
};
M::M(unsigned int i) { n = i; }
class A {
protected:
char t;
public:
virtual ~A();
virtual std::vector<M> foo(unsigned int);
char getChar();
};
A::~A(){}
std::vector<M> A::foo(unsigned int u) {
std::vector<M> v;
return v;
}
char A::getChar() { return t; }
class B : public A {
public:
B();
std::vector<M> foo(unsigned int);
};
B::B() { t = 'b'; }
std::vector<M> B::foo(unsigned int c) {
std::vector<M> v;
for (unsigned …Run Code Online (Sandbox Code Playgroud) c++ ×3
c++03 ×2
ascii ×1
class ×1
constructor ×1
expression ×1
html ×1
java ×1
object ×1
php ×1
polymorphism ×1
string ×1
virtual ×1