将以下c程序转换为php [英] convert below c program to php

查看:60
本文介绍了将以下c程序转换为php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 main()
{
char c;
printf( 输入y表示是,n表示没有\ n);
scanf( %c,& c);
if (c == ' y'
{
执行一些陈述

}
else
{
一些陈述
}
}

解决方案

你必须从用户那里获取输入JS提示然后用PHP做这样的事情



echo(输入Y表示是,N表示否)



if(//此处提示值==Y)

//声明

其他



//声明


php没有控制台输入用户输入它只是在服务器端网页下工作


如果你想要在控制台中运行php有一个简单的解决方案,从php的第4版开始直到今天(我的版本是7.2)这是readline。

不幸的是他需要用户在输入后按Enter键/>

  

main()
{
char c;
printf("enter y for yes and n for no \n");
scanf("%c",&c);
if(c=='y')
 {
execute some statements

}
else
{
some statements
}
}

解决方案

You'll have to take input from user in JS prompt then do some thing like this in PHP

echo("Enter Y for yes and N for no")

if(//prompt value here == "Y")
//statement
else

//statement


php dose not have a console to enter user input it just work under server side web page


If you want to run php in the console has a simple solution that works from version 4 of php until today (my version is 7.2) that is the readline.
Unfortunately he needs the user to press enter after typing


这篇关于将以下c程序转换为php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆