PHP-HTML variable Communication [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
My C++ program communicates to my PHP server through a TCP socket.
Data is sent on the server at periodic intervals.
I want the Data sent on the server to be displayed on my HTML page.
I am new to HTTP/PHP programming. How can I achieve this.
Thanks in advance.

There are a lot of ways to do this, the most simple should be this one (if your c++ program run out of the server):
create a "upload.php" file in your server with:
<?php
$a = $_POST["data"];
//$a contains all your data
?>
send a POST message to
http://yourserver/upload.php
from your c++ program with 'data' parameter containing your data message. You can use libcurl to achieve this. Here is an example How do you make a HTTP request with C++?

c++ to PHP use Socket
PHP to HTML use HTTP
To run PHP you will need to install apache.

Related

Can we Use php script in Google Tag Manager [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Just wondering if a php code could be executed via Google Tag manager?
Thanks
No. The Google Tag Manager inserts client-side Javascript. PHP requires a server that is configured for PHP. Inserting a PHP script via GTM would just output the raw PHP code to the browser, it would not execute the code.
If you want to include the results of a PHP Script you would have to run the script on your own server and fetch the results via Javascript as suggested in UncleRicos answer.
I would look at Custom Events in Triggers here: https://support.google.com/tagmanager/answer/6106961?hl=en&ref_topic=3441647&vid=1-635797415927700239-1991783559
You can specify a javascript event that would be called upon a trigger being executed, which in turn could call a routine via ajax (which could be PHP or anything).

Send data to the client now, and continue PHP processing [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible in PHP, to send the data right now to the client, and continue the PHP processing (that might be blocking) ?
<?php
// some code
echo json_encode(array('ok' => '1')); // the client is waiting for this AJAX answer !!
// how to send the response right now before finishing this PHP file ?
// the output is REALLY finished here, so client, you can work with it
some_blocking_processing(); // this is just some server processing that would
// block the client for ~ 5 seconds
// but it produces no output useful for client
?>
I know the right way might be to use queues or other process to perform the processing.
But just as a general purpose question, is it possible to send the data to the client, in the middle of a PHP file?
Well it really depends on what some_blocking_processing() is actually doing. I can't come up with a solution without knowing what is happening there.
However I can point you to some areas where you can do more research. One of these might be the right solution for you:
PHP threading
spawning asynchronous php process
logging your state in file/db and then do the extra processing via a cron job

How to Run C code in WebBrowser using PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Suggest a method to take input as command-line-arguments from a single text-box in Web-Browser.
These numbers are then added using C code and Display the result again in the Web-Browser.
Suggest, How can I use PHP or HTML to link my C code?
I haven't done php for a long time now ...
If I understand you well I would do that :
Your html should send the request (http GET request) with the two numbers to your server (from your form).
The triggered php script should use the shell_exec command from php to execute a c program.
The program shall print the sum to the console (http://php.net/manual/en/function.shell-exec.php).
Then the result string would be sent back to the webbrower
I hope I'm right.

Run PHP client side [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Is it possible to launch a PHP script, client side, using an HTML web page?
If not, is there a way to embed the PHP into the HTML so it can run client side?
I think what you want is JavaScript. PHP is meant for server-side and JavaScript is meant for client side, among other things.
No. PHP cannot be run in browser. Learn JavaScript, alternatively CoffeScript if you don't like JavaScript's syntax.

recieve file send by client socket using PHP sever socket [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to save file send by client using PHP server socket. I am newbie to PHP socket programming.
Does anyone know possible options?
-SAM
Have look at this snippet, it recieves a file sent to the php socket server then saves it on the server:
http://www.example-code.com/php/socket_receiveFile.asp
Alternatively you could develop your own solution, but then you'd have to:
Create a binary structure for what each request looks like. For example you need to create predefined header that the server can read to know what type of request it is, what type of data it is, where the data starts in the file and what to do with the data.
Create a binary parser which will read the header and which can take the binary data and turn it into a file and then save it.

Categories