我正在尝试使用if三元运算符识别我的页面(用于菜单)。
$page_name = "workers";
($page_name != "home") ? echo "home";
所以我认为应该出现“家”,但不是。 Parser向我显示错误:
解析错误:语法错误,意外'?'
我做错了什么?
答案 0 :(得分:1)
你ternary syntax错了,试试这个:
// Vertex Shader Code
var vertexShaderText = [
'precision mediump float;',
'',
'attribute vec2 vertPosition;',
'',
'void main() {',
' gl_Position = vec4(vertPosition, 0.0, 1.0);',
'}'
].join('/n');
// Fragment Shader Code
var fragmentShaderText = [
'precision mediump float;',
'',
'void main() {',
' gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);',
'}'
].join('/n');
var initApp = function() {
// Check for errors
console.log("The app is working so far");
var canvas = document.getElementById('game-canvas');
var gl = canvas.getContext('webgl');
if (!gl) {
gl = canvas.getContext('experimental-webgl');
}
if (!gl) {
alert('Sorry, your web browser does not support WebGL. Please try opening this page in a different browser.');
}
// Clear color and depth buffers and set the background window color
gl.clearColor(0.3, 0.7, 0.5, 0.7);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Create vertex and fragment shader objects
var vertexShader = gl.createShader(gl.VERTEX_SHADER);
var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
// Load and compile shaders from code provided in 'vertexShaderText' and 'fragmentShaderText'
gl.shaderSource(vertexShader, vertexShaderText);
gl.shaderSource(fragmentShader, fragmentShaderText);
gl.compileShader(vertexShader);
gl.compileShader(fragmentShader);
// Check for GL compilation errors (because they often are not explicit)
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
console.error('Error compiling vertex shaders:', gl.getShaderInfoLog(vertexShader));
}
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
console.error('Error compiling fragment shaders:', gl.getShaderInfoLog(fragmentShader));
}
};