我有一个来自php的响应,它是一个缩小的脚本,可以通过DB调用等从服务器更改一些变量。示例响应如下:
var primaryColor = '172983';var secondaryColor = '102429';var headerLogoImg = 'https://rb1.net/images/logo.png';var headerDefaultLogo = 1;function hexToRgb(hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? parseInt(result[1], 16) + "," + parseInt(result[2], 16) + "," + parseInt(result[3], 16) : null;}
但是我希望以这样一种漂亮的格式发送响应:
var primaryColor = '172983';
var secondaryColor = '102429';
var headerLogoImg = 'https://rb1.net/images/logo.png';
var headerDefaultLogo = 1;
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? parseInt(result[1], 16) + "," + parseInt(result[2], 16) + "," + parseInt(result[3], 16) : null;
}
如何使用print或echo或任何内置的php函数? 我不想手动插入缩进和换行符。