can someone help me with this code?
Is it better to use WordPress with React or only use WordPress?
WordPress with react?
the theme is built in react?
cpnael or pleask?
This structure correct sharing api ?
did you turn on php error?
Ecommerce application
<!DOCTYPE html>
<html>
<head>
<title>Task 5</title>
</head>
<body>
<?php
include ‘menu.inc’;
?>
<main>
<?php
echo “……………..Task 5 (A)……………..”.” <br>
“#Create function;
function getResult($assMarks) {
if($assMarks >=75)
{
echo “Distinction <br>”;
}
else if($assMarks >=40 && $assMarks<49)
{
echo “You qualify for supplementary <br>”;
}
else if($assMarks >=50)
{
echo “Pass <br>”;
}
else
{
echo “Fail <br>”;
}
}
echo getResult(25);
echo getResult(40);
echo getResult(45);
echo getResult(50);
echo getResult(74);
echo getResult(95);
?>
//End Task 5 A /////////
echo “…………..Task 5 (B)……………
// for loop
for($i=1; $i<=10; $i++){
if($i%2 != 0)
echo “$i – odd number <br>”;
else
echo “$i – Even number <br>”;
}
echo “………..Do While Loop……………….
//do while loop
$i = 1;
do{
if($i % 2 != 0){
echo “$i – Odd number <br>”;
}else{
echo “$i – Even number <br>”; }
$i++;
}while ($i <= 10);
echo “………………..Task 5 (C)……………..
echo “<br>”;
for($i=1; $i<=10; $i++) {
$randNum = rand(1,4);
switch($randNum)
{ Case 1:
echo ‘North ‘.'<br>’;
break;
Case 2:
echo ‘south ‘.'<br>’;
break;
Case 3:
echo ‘East ‘.'<br>’;
break;
Case 4:
echo ‘West ‘.'<br>’;
break;
}
}
?>
</main>
<!– iframe containing PHP source code —>
<iframe src=”task5.txt” width=”1200″ height=”400″>Your browser does not support iframe.</iframe>
</body>
</html>
your echo statements are missing ending quotes
there are many, go to YouTube
Use json decode like this ….
$a=json_decode($b,true);
$object=$a->(key of object for example : name )
Actually $b is your json encoded
postman is for api testing, on they body, form data, there give the json
WordPress with react?
yes
by Bret Cameron Combine the power of a React front-end with the internet’s most popular CMS Want the advantages of a modern React SPA, but need a back-end that feels familiar? In this article, we’ll go through how to set-up WordPress’s REST API, including custom posts types and fields, and
$a=json_decode($b,true);
$object=$a->(key of object for example : name )
Actually $b is your json encoded
When i follow this method its shows error !
Share error code please
$json = json_decode($fgc, true);
$firstname = $json[‘firstname’];
$lastname = $json[‘lastname’];
$json = json_decode($fgc, true);
$firstname = $json[‘firstname’];
$lastname = $json[‘lastname’];
you can use extract( $json) it will make variable with name same as in the json with the values
turn on display_errors to see erros on php settings
cpnael or pleask?
https://www.a2hosting.com/kb/cpanel/cpanel-software/changing-php-versions-and-settings-in-cpanel this may help
cPanel accounts may be have multiple PHP versions available. This article shows how to switch between them using the PHP Selector
or
ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL);
on the page where the error is coming
if there is error it will show


$a=json_decode($b,true);
$object=$a->(key of object for example : name )
Actually $b is your json encoded
Check your ib dude
you are using third party api
no error?