-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathteste.php
More file actions
103 lines (76 loc) · 2.37 KB
/
Copy pathteste.php
File metadata and controls
103 lines (76 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
session_start();
/*
echo "Session:<pre>";
print_r($_SESSION);
echo "</pre>";
echo "Get:<pre>";
print_r($_GET);
echo "</pre>";
//*/
echo "BASE: ".$_GET['base']."<br>";
echo "EXPOENTE: ".$_GET['exp']."<br>";
if(!isset($_SESSION['bases']))
$_SESSION['bases'] = array();
if(!isset($_SESSION['expoentes']))
$_SESSION['expoentes'] = array();
if(!isset($_SESSION['dbases']))
$_SESSION['dbases'] = array();
if(!isset($_SESSION['dexpoentes']))
$_SESSION['dexpoentes'] = array();
if(isset($_GET['base']) && isset($_GET['exp'])){
array_push($_SESSION['bases'], $_GET['base']);
array_push($_SESSION['expoentes'], $_GET['exp']);
array_push($_SESSION['dbases'], $_GET['base']*$_GET['exp']);
array_push($_SESSION['dexpoentes'], $_GET[exp]-1);
}
echo "Session:<pre>";
print_r($_SESSION);
echo "</pre>";
/*
$_SESSION = array();
echo "ini<pre>";
print_r($_SESSION);
echo "</pre>";
//*/
echo "<form>";
echo "<input type=\"number\" name=\"base\" required>";
echo "<input type=\"number\" name=\"exp\" required>";
echo "<input type=\"submit\" value=\"Resolver\">";
echo "</form>";
for ($i=0; $i < count($_SESSION['bases']); $i++) {
// So printa algo se a base nao for 0
if($_SESSION['bases'][$i]!=0){
// Verificar e printar '+ ou '-'
if($i!=0 && $_SESSION['bases'][$i]>0) echo " + ";
elseif ($_SESSION['bases'][$i]<0) echo " - ";
// Verificacao para printar a base
if( abs($_SESSION['bases'][$i])!=1 || $_SESSION['expoentes'][$i]==0 )
echo abs($_SESSION['bases'][$i]);
// Verificacao para printar o 'x' e o expoente
if($_SESSION['expoentes'][$i]!=0){
echo "x";
if($_SESSION['expoentes'][$i]!=1)
echo "<sup>".$_SESSION['expoentes'][$i]."</sup> ";
}
}
}
echo "<br>";
for ($i=0; $i < count($_SESSION['dbases']); $i++) {
// So printa algo se a base nao for 0
if($_SESSION['dbases'][$i]!=0){
// Verificar e printar '+ ou '-'
if($i!=0 && $_SESSION['dbases'][$i]>0) echo " + ";
elseif ($_SESSION['dbases'][$i]<0) echo " - ";
// Verificacao para printar a base
if( abs($_SESSION['dbases'][$i])!=1 || $_SESSION['dexpoentes'][$i]==0 )
echo abs($_SESSION['dbases'][$i]);
// Verificacao para printar o 'x' e o expoente
if($_SESSION['dexpoentes'][$i]!=0){
echo "x";
if($_SESSION['dexpoentes'][$i]!=1)
echo "<sup>".$_SESSION['dexpoentes'][$i]."</sup> ";
}
}
}
?>