Get page with PHP or Ajax?

0

I have the following código to get pages in my content with url :

<?php
$url = (isset($_GET['url'])) ? $_GET['url'] : 'home';

$url = array_filter(explode('/', $url));

$file = './pages/' . $url[0] . '.php';

if (is_file($file)) {
  include_once $file;
} else {
  include_once './pages/404.php';
}
?>

But then the question arose, "?", what better method to do this, with php or ajax ? Which is more secure, which interferes more with the SEO of WebSite? Which is more agile?

    
asked by anonymous 24.06.2017 / 01:49

1 answer

0

I think I understand your question. Well, let's go.

1st - AJAX can not be compared to PHP because it is a Jquery plugin to do things like requests without the refresh on the page or even receive texts like JSON or do a validation of password , all this taking into account that you are using php as a backend.

2nd - PHP is the best way to do what you want. For you are doing includes of files on your page and probably those includes contain values and variables that need to be used somewhere in your code.

    
24.06.2017 / 13:28