我很困惑如何接受来自Erlang shell或eclipse控制台的输入? 我想接受来自用户的变量“input”的输入。
p1()->
io:format(" codes for bussiness logic of task one \n"),
spawn(xorgateway, xor_split, []).
xor_split()->
io:format("enter your decision \n").
case Value of
decision1 ->
spawn(xorgateway, p2, []);
decision2 ->
spawn(xorgateway, p3, []);
decision3 ->
spawn(xorgateway, p4, []);
_->
io:format("invalid input \n")end.
答案 0 :(得分:4)
我很困惑如何接受来自Erlang shell的输入
function saveProfilePic()
{
# I would not do this, I would put the connection at the top of the page and
# inject the $con into the function saveProfilePic($con)
include_once("config/config.php");
# I would check for !empty(), not isset() because it could be set, just empty
$post = (!empty($_POST))? $_POST : array();
# Check for just id here not username-id
if(!empty($post['id'])) {
# You should be binding parameters, forget using the escaping stuff...
$username_id = mysqli_escape_string($con, $post['id']);
$sql_query = "SELECT * FROM users WHERE username = '".$username_id."'";
$resultset = mysqli_query($con, $sql_query) or die("database error:". mysqli_error($con));
if(mysqli_num_rows($resultset)) {
# Again, bind parameters here, don't escape anymore
$sql_update = "UPDATE users set profile_pic='".mysqli_escape_string($con,$post['image_name'])."' WHERE username = '".$username_id."'";
mysqli_query($con, $sql_update) or die("database error:". mysqli_error($con));
}
}
}
在shell中:
-module(my).
-compile(export_all).
get_data() ->
{ok, Term} = io:read("Enter a number: "),
io:format("The number you entered plus one is: ~w~n",
[Term + 1]).
请注意,用户需要在输入后输入一段时间。另请参阅io:getline()和io:fread()
我想接受变量"输入"
的输入
8> c(my).
my.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,my}
9> my:get_data().
Enter a number: 10.
The number you entered plus one is: 11
ok
10>
不是Erlang中的变量。 Erlang变量以大写字母开头。