dongtanzhu5417 2019-01-26 22:40 采纳率: 100%
浏览 61
已采纳

如何将变量从java转换为php?

I'm creating player panel for my friend in php, but I have problem with variable shown below. I must insert into variable in php, and send request to database. What is my problem? I can't convert java code, because I don't know how I can do this. It may be strange, but unfortunately it is.

I tried do this with amateur way, using; require 'mojang-api.class.php';

$uuid = MojangAPI::getUuid('jeb_');
echo 'UUID: <b>' . $uuid . '</b><br>';
echo substr($uuid, 0, 8); echo '-'; echo substr($uuid, 8, 12); echo '-'; substr($uuid, 13, 15); echo '-';

but, You and I know this - this way sucks.

I place the java code below.

Java:

uuid.substring(0, 8) + '-' + uuid.substring(8, 12) + '-' + uuid.substring(12, 16) + '-' + uuid.substring(16, 20) + '-' + uuid.substring(20)

If someone can help me with this problem, I'll be grateful.

  • 写回答

1条回答 默认 最新

  • dougan0529 2019-01-26 23:21
    关注

    Is this what you are looking for

    $uuid = MojangAPI::getUuid('jeb_');
    echo 'UUID: <b>' . $uuid . '</b><br>';
    echo substr($uuid, 0, 8).'-'.substr($uuid, 8, 4).'-'.substr($uuid, 13, 2);
    

    Instead of plus + in Java you use the dot . in PHP. Amazingly you used it in the line above?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题