Skip to content

Capturing and displaying exec/shell_exec periodic output?

You can easily use exec() or shell_exec() to execute a system command, like ls -l /var/www/mysite and then output the result of the command. How would one execute and display the result of a command that periodically prints information out to the console? You have a simply Python script. If you run the script…

PHP “php://input” vs $_POST

I have been directed to use the method php://input instead of $_POST when interacting with Ajax requests from JQuery. What I do not understand is the benefits of using this vs the global method of $_POST or $_GET. Answer The reason is that php://input returns all the raw data after the HTTP-headers of the req…

Change Form Elements Depending On Selected Option

I have seen several sites where there is a form, starting with a dropdown box, and depending on the box chosen there is different form elements, for example, let’s say I wanted to make an uploader script, the dropdown box might hold: And is Upload is selected I would want a browse file element, while wi…

array of arrays to array of objects php

I am trying to convert the associative array to an array of objects. $assoc = array ( array( ‘prop1’=>’val1’, ‘prop2’=>’val2’, ), array( ‘prop1’=>’val1’, ‘prop2’=>’val2’, …

PHP convert XML to JSON

I am trying to convert xml to json in php. If I do a simple convert using simple xml and json_encode none of the attributes in the xml show. $xml = simplexml_load_file(“states.xml”); echo json_encode(…