Ich mag würde jede meiner virtuellen Hosts Konfigurationen greifen und sie in einem Array setzen mit preg_match_all so kann ich Informationen von jedem von ihnen extrahieren, zum Beispiel ...preg_match_all zwischen dynamischen Tags
$vHostConfig = ' <VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName testing.com
DocumentRoot c:/wamp/www/testing.com
<Directory "c:/wamp/www/testing.com">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName testing2.com
DocumentRoot c:/wamp/www/testing2.com
<Directory "c:/wamp/www/testing2.com">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# <VirtualHost *:80>
# ServerName testing3.com
# DocumentRoot c:/wamp/www/testing3.com
# <Directory "c:/wamp/www/testing3.com">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
# </Directory>
# </VirtualHost>';
preg_match_all(<<what to put here>>, $vHostConfig, $vHostConfigMatches);
würde ich Ich mag nur die aktiven Konfigurationen ohne ein # am Anfang der Zeile, was bedeutet, dass ich drei Strings haben sollte, die mit <VirtualHost
beginnen und mit </VirtualHost>
im Array $ vHostConfigMatches enden. Ist das möglich?
während Regex kann dies tatsächlich tun, ist es erwähnenswert, dass eine Art von DOM-Parser wird viel besser und wahrscheinlich effizienter dabei sein. [Anmerkung 1] (http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) :: [Anmerkung 2] (https: // nikic.github.io/2012/06/15/The-true-power-of-regular-expressions.html) – Martin
Ich benutze diesen Code nicht in einem Browser, es ist einige benutzerdefinierte Code für die Verwaltung meiner virtuellen Hosts, es ist so Ich kann benutzerdefinierte Funktionen in meinem Wamp-Menü erstellen – Dan
XHTML ist immer noch DOM strukturiert, unabhängig davon, was Sie mit ihm sehen. – Martin