W
W
wolverine7772019-06-18 12:31:35
PHP
wolverine777, 2019-06-18 12:31:35

Separation of the "request" and the web page - what is it about?

Hello,
Need more philosophical advice to understand what is at stake. As probably many of those who answered my other questions already understood - I am at an early stage of development in the field of understanding SNMP protocols and computer science in general .. In addition to snmp, I had to start learning PHP as best I could - as a dz I had to write a script that displays the status of a hard disk - how much free space is left and a warning if the percentage of free space exceeds a certain number.
That's what I wrote - everything is fine,

<?php
snmp_set_quick_print(TRUE);

$host='127.0.0.1';
$community='public';

$hddtotal=snmpget($host,$community,'.1.3.6.1.4.1.2021.9.1.6.1');
$hddavail=snmpget($host,$community,'.1.3.6.1.4.1.2021.9.1.7.1');
$hddused=snmpget($host,$community,'.1.3.6.1.4.1.2021.9.1.8.1');


echo "TOTAL size of the disk (in kBytes): ".$hddtotal;
echo "</br>";
echo "Available space on the disk: ".$hddavail;
echo "</br>";
echo "Used space on the disk: ".$hddused;
echo "</br>";

$percentage=round($hddused*100/$hddtotal);

echo "Your machine is currently using about <b>". $percentage."</b>% of total disk space";
echo "<hr>";
$diskleft=100-$percentage;

if ($percentage > 3) {echo "<p> <font color=red>Warning!</font></p> You have only ". $diskleft."% of disk space left!";}
else {echo "Your disk space isn't critical";}

?>

everything works, but my "mentor" told me the following:
You have to consider two things when you develop in PHP. The probe and the webpage.
Clearly there is misunderstanding.
You put together the probe and the target to display the result.
You have to split that. One part to make SNMP request and result analysis and another part to show - which is the webpage.

Please help me figure out what is it about? What does the person mean? I roughly guess that he is probably talking about MVC - but what if I'm sitting in Linux?
Currently, I just have an index.php page that is displayed at localhost/~username and actually contains the above code.
I will be very grateful for your help.
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lazy @BojackHorseman PHP, 2019-06-18
Tag

it's about separating logic and presentation

A
AUser0, 2019-06-18
@AUser0

Apparently a separate function for requesting input data, a separate SNMP receive function, a separate HTML output function, and a separate function for calling the first, second and third.

R
Ruslan Ruslanov, 2019-06-19
@dasauser

well try this first

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question