什么是PHP中的REST API?使用JSON解释一个例子? [英] what is REST API in PHP?explain with an example using JSON?

查看:90
本文介绍了什么是PHP中的REST API?使用JSON解释一个例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai,

我对PHP域中的REST API概念非常陌生,我处于使用它的状态。

任何人都可以帮助我解释这个概念。



用PHP中的普通GET和POST方法区分REST API。



还请给我一个简单的例子,在php中使用REST API显示一个人的姓名和年龄,也就是说,例如,当用户使用post方法点击提交按钮时,我有编码显示姓名和年龄。 />


我需要使用REST API的相同示例。



Hai,
I am very new to the REST API concepts in PHP domain and I am in a situation to use it.
Can any one please help me by explaining this concept.

Differentiate the REST API with the normal GET and POST method in php.

And also please give me a simple example in php using REST API for displaying the name and age of a person, that is, for example I have the coding to display name and age when the user clicks the submit button using post method.

I need the same example using REST API.

<?php

  if( $_POST["name"] || $_POST["age"] )

  {

     echo "Welcome ". $_POST['name']. "<br />";
     echo "You are ". $_POST['age']. " years old.";
     exit();
  }
?>
<html>
<body>
  <form action="<?php $_PHP_SELF ?>" method="POST">

  Name: <input type="text" name="name" />
  Age: <input type="text" name="age" />

  <input type="submit" />
  </form>
</body>
</html>





在此先感谢!!!

请给我一个解决方案!^



Thanks in Advance!!!
Please give me a solution!^

推荐答案

_POST [name] ||
_POST["name"] ||


_POST [age]

{

echo 欢迎 < span class =code-summarycomment>
_POST["age"] ) { echo "Welcome ".


_POST ['name']。 < br / > ;
echo你是。
_POST['name']. "<br />"; echo "You are ".


这篇关于什么是PHP中的REST API?使用JSON解释一个例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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