Answer the question
In order to leave comments, you need to log in
How to create custom macros for text in PHP?
Hello,
I have a question how to create my own macros for text in PHP so that they can be fully managed, etc.?
Regular str_replace(); not suitable because I still need the ability to escape the macro (with the "\" character), and I also need the ability to multi-level replacement.
<?php
$macros = [
"{user}" => "Вася",
"{date}" => date("d.m.y"),
"{user_id}" => 1,
"{rand:(min):(max)}" => rand($min, $max)
];
$text = "Привет {user}, сегодня {date}. Ваш ID {user_id}. Ваше рандомное число -- {rand:0:10}";
echo replace($text);
Answer the question
In order to leave comments, you need to log in
You can, this technology is called nested virtualization.
Works quite successfully in KVM and Hyper-V.
In order to use with kvm, support from the host system is required, 99% that the host will not enable it.
Ask this question to the technical support of the hosting. The possibility of nested virtualization depends on the settings of the host hypervisor. On commercial vds hosting, this will most often not be possible. You will simply be offered to take a server and configure and install anything on it.
If I were you, I would look at soyoustart.com or even kimsufi.com
To get rid of problems, I recommend renting several inexpensive vps.
You can search here: https://lowendbox.com/
if you need something more complicated than placeholders, then look towards preg_replace_callback_array, otherwise see ffosters answer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question