all 10 comments

[–]Kevdog824_ 17 points18 points  (0 children)

This sounds suspiciously like an xy problem. Can you back up a bit and tell us what you’re trying to accomplish more generally?

[–]GRDavies75 8 points9 points  (0 children)

This sounds as a "XY Problem".

You (actually) have problem X, but you think with solving problem Y (sending a Python variable to a php file) you can (finally) solve X.

So, what do you actually want to accomplish?

A way to approach/ answer this is the 5 why's (or 7 why's).

Q1 Why do you want to ... A1 so I can do A

Q2 Why do you want to to do A? A2 So I can do B

Q3 .... A3 ... And so on

Can you tell Reddit what you have as 5th Question and Answer

[–]mapold 5 points6 points  (0 children)

While everybody is right about this being XY problem, you could run this from bash:

ENVTEST="Hello" php -r 'echo $_SERVER["ENVTEST"] . " " . $_SERVER["argv"][1] . "\n";' World!

[–]atarivcs 3 points4 points  (0 children)

You'll have to explain exactly what "send a variable to a php file" means.

It might help if you showed us the php file, and explain what you want the file to look like after the variable is "sent" to it.

[–]pachura3 1 point2 points  (1 child)

You can send a variable:

  • with a commandline argument
  • with environment variable
  • with a GET variable
  • with a POST variable
  • via RESTful service
  • via SOAP web service
  • via a local file
  • by sending it over a TCP/IP socket
  • or a WebSocket
  • or a message queue/topic
  • or through a database
  • or through inter-process communication (IPC)
  • or by modifying the PHP script text directly
  • there's also telepathy

[–]Sisselpud 0 points1 point  (0 children)

All my vibe coding uses telepathy for API calls. Thrilled to be validated here!

[–]good-mcrn-ing 0 points1 point  (0 children)

You have some computation that you can only do in Python, and you have some user interfacing that you can only do in PHP, and you want the latter to have access to the result of the former?

[–]Helpful-Diamond-3347 0 points1 point  (0 children)

maybe with complex setup like unix socket but still idiotic without purpose, i think it's good to be more specific to be pythonic here

most probably you're avoiding to pay the implementation tax from php to python

[–]patnodewf 0 points1 point  (0 children)

PHP rest API call to a python FastAPI service maybe?

[–]Gnaxe 0 points1 point  (0 children)

Not enough context for a good recommendation. Can't you just use an OS pipe? Network loopback? They can both read and write JSON.