preventing access to php files using htaccess doesnot allow ajax to use php files
I've no idea what you're trying to accomplish, but I believe you're seriously misguided about how a PHP-based website works.

If you set up .htaccess-rules to stop the browser from accessing any PHP-file, it is not only ajax that will be affected.  Every page on your Drupal website will return 403 to any visitor, including index.php in the root directory.  I doubt that you want this.

If you've got Apache configured correctly for PHP, the contents of a PHP-file are never transmitted to the client - only the result of processing it server side.  Just point your browser to sites/default/default.settings.php to see how this works.  Unless you've really munged your Drupal configuration, you should not need to do anything to stop the PHP-files from being browsed.