D
D
Daniel2018-02-26 00:15:50
PHP
Daniel, 2018-02-26 00:15:50

The main life cycle of a PHP program?

A newbie in php, I don’t understand everything, but where is the entry point of the program, as in nodeJS or JAVA, for example, there is an array with goods, the user sends a request to purchase a product, the selected product decreases in the array, and this array exists only for this user, i.e. with 1000 requests, I will create 1000 of these arrays and at the same time they will not change at all after the response is sent, and I need this one array to work with all users, I did not find an explanation for half the tutorial. You need to build a simple api that would remember everything while the server is running, without subds and files.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
X
xmoonlight, 2018-02-26
@xmoonlight

klisl.com/memcache.html

and I need this one array to work with all users, I did not find an explanation for half the tutorial.
transaction in the database.

S
Stalker_RED, 2018-02-26
@Stalker_RED

PHP

Perhaps you should choose a different platform.
You can, of course, get confused and do it in PHP (a demon that would remember it in memory), but it's better not to when there are such problems with reading.

M
Mikhail Bobkov, 2018-02-26
@mike_bma

without subd and files.

And what happens to the data if the server suddenly stops working? Will the current number of goods be lost? Will your order history disappear?
Those. to save the data, we already need to write it somewhere after the change (to a file or database).

A
asd111, 2018-02-26
@asd111

redis or memcache

A
Alexander, 2018-02-26
@Minifets

If you want an "undying" http server like express in node.js, then use ReactPHP . Natively in php, what you need cannot be done.

V
vanyamba-electronics, 2018-02-27
@vanyamba-electronics

The entry point to a program is denoted in PHP as follows:
<?php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question