Linux Format

PHP flexibilit­y

-

With AngularJS, especially for newcomers, many of your usual repeat tasks can become more complicate­d to implement. Thus, if your files for your applicatio­n are PHP files, you have options to switch in and out of an Angular applicatio­n.

To make this process simple, you can do a few things. With our example, let’s say you have a website and want to run Captcha2. The first step you can take is to change a link in your main menu, footer and wherever else from something like <a href="#/contact"> to the actual PHP page. This means the new link will look like <a target="_self” href="contact-us.php">. The target is required. This a new workaround for the Angular route. But since the index.php page is an Angular app, you need to ‘deangulari­se’ it for the contact-us.php page. If the code ( right) is inserted into the top of the index.php page, the ng-app="myApplicat­ion” will not become part of the code when the contact-us.php is opened. Without ng-app, no angular. Now, there’s no point in having Angular tags when the contactus.php file opens. At this point, you could easily use the Google API for Captcha2: <?php if (basename($_SERVER['SCRIPT_ NAME']) != 'contact-us.php'){?> <html ng-app="myApplicat­ion"> <?php } else{ ?> <html> <?php } ?>

Newspapers in English

Newspapers from Australia