PHP Interview Questions for Accenture

1. How is PHP used in enterprise-level solutions like those delivered by Accenture?
PHP is used to build scalable web applications, RESTful APIs, customer portals, business intelligence dashboards, and for integrating legacy systems with modern cloud solutions.


2. How do you handle secure API communication in PHP?

  • Use HTTPS with strong TLS configurations.
  • Implement OAuth2 or JWT tokens for authentication.
  • Validate all incoming requests and sanitize inputs.

3. How do you manage environment-specific configurations securely?

  • Store configurations in .env files.
  • Use environment variables and secure secrets management tools.

4. How do you handle multi-cloud integration in PHP applications?

  • Use platform-specific SDKs or REST APIs for services like AWS, Azure, and GCP.
  • Ensure proper API key management and role-based access control.

5. How do you implement microservices architecture in PHP?

  • Break down services into independent RESTful APIs.
  • Use Docker and Kubernetes for containerization and orchestration.

6. How do you prevent SQL Injection in PHP applications?

  • Use PDO or MySQLi prepared statements.
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$id]);

7. How do you optimize a PHP application for high availability?

  • Use load balancers and horizontal scaling.
  • Implement caching mechanisms with Redis or Memcached.
  • Optimize database queries and use read replicas.

8. How do you handle session storage in scalable applications?

  • Store sessions in Redis or Memcached instead of files.
  • Use secure cookies with HttpOnly and Secure flags.

9. How do you implement secure file uploads?

  • Validate file types and size limits.
  • Store files outside the web root and generate unique filenames.

10. How do you manage version control for large PHP projects?

  • Use Git with structured branching strategies like GitFlow.
  • Ensure code reviews and CI/CD pipelines for automated deployments.

11. How do you manage background processing in PHP?

  • Use job queues like RabbitMQ, Redis Queue, or Beanstalkd.
  • Process jobs asynchronously using worker scripts.

12. How do you ensure API scalability?

  • Implement API Gateway solutions.
  • Cache API responses.
  • Use asynchronous API processing for heavy tasks.

13. How do you handle authentication in REST APIs?

  • Use JWT tokens or OAuth2 for stateless authentication.
  • Validate tokens for each API request.

14. How do you secure sensitive configuration files?

  • Keep them outside the web root.
  • Set strict file permissions.

15. How do you implement audit logs in enterprise applications?

  • Record critical events (CRUD actions, logins, config changes) with user IDs and timestamps.
  • Store logs securely and periodically archive them.

16. How do you handle failover scenarios in a PHP application?

  • Use database replication and automatic failover mechanisms.
  • Deploy services in multiple availability zones.

17. How do you ensure GDPR compliance in your PHP applications?

  • Encrypt personal data.
  • Allow users to delete and export their data.
  • Log consent and data access activities.

18. How do you implement CSRF protection?

  • Generate CSRF tokens for each form.
  • Validate tokens before processing form data.

19. How do you handle secure API rate limiting?

  • Track API requests per IP or token using Redis.
  • Return 429 Too Many Requests when limits are exceeded.

20. How do you manage API versioning?

  • Include version in API URLs (e.g., /api/v1/users).
  • Deprecate older versions gracefully.

21. How do you integrate payment gateways in PHP?

  • Use official SDKs or APIs of gateways like PayPal, Stripe, or Razorpay.
  • Handle callbacks and verify payment statuses securely.

22. How do you implement secure password storage?

  • Use password_hash() and password_verify().
  • Enforce strong password policies.

23. How do you handle timezone differences in a global application?

  • Store all timestamps in UTC.
  • Convert to local time zones using PHPโ€™s DateTimeZone class when displaying data.

24. How do you handle large file downloads efficiently?

  • Stream files in chunks using readfile() or output buffering.
  • Set appropriate HTTP headers for downloads.

25. How do you handle Single Sign-On (SSO) integration?

  • Integrate using OAuth2 or SAML protocols with identity providers like Azure AD or Okta.

26. How do you prevent Cross-Site Scripting (XSS) attacks?

  • Sanitize and escape user inputs using htmlspecialchars().
  • Implement Content Security Policy (CSP) headers.

27. How do you handle duplicate form submissions?

  • Use unique tokens per form submission.
  • Validate the token before processing and invalidate it after use.

28. How do you calculate the difference between two dates?

$start = new DateTime('2024-01-01');
$end = new DateTime('2024-12-31');
echo $start->diff($end)->days;

29. How do you implement API key management for external partners?

  • Issue unique API keys per partner.
  • Implement scopes and rate limits per API key.

30. How do you handle OTP-based authentication?

  • Generate and store OTPs securely with expiry times.
  • Validate OTPs before proceeding with sensitive operations.

31. How do you handle optimistic locking to avoid concurrent update issues?

  • Add a version field to records.
  • Compare versions before committing updates.

32. How do you ensure secure redirects?

  • Validate redirect URLs against an allowed list.
  • Avoid using user-supplied URLs directly.

33. How do you implement multi-currency handling in a PHP application?

  • Store base currency values and convert using live exchange rates during transactions.

34. How do you manage multi-language support in enterprise portals?

  • Store translations in language files or database tables.
  • Load the appropriate language dynamically based on user preferences.

35. How do you prevent brute-force login attempts?

  • Implement IP rate limiting.
  • Add CAPTCHA after multiple failed login attempts.

36. How do you integrate messaging services like Twilio or SendGrid?

  • Use their official SDKs or REST APIs.
  • Secure API keys and handle retries on failures.

37. How do you generate PDF reports in PHP?

  • Use libraries like Dompdf or TCPDF to generate and download PDF reports.

38. How do you handle real-time notifications?

  • Use WebSockets with services like Pusher.
  • For server-sent events, implement long-polling or push notifications.

39. How do you handle bulk data imports efficiently?

  • Process files in batches using fgetcsv().
  • Validate data before inserting into the database.

40. How do you implement disaster recovery strategies?

  • Take regular backups.
  • Set up failover databases and services.
  • Test recovery procedures regularly.

41. How do you handle concurrent API requests that modify the same data?

  • Use database-level transactions and locks.
  • Implement optimistic or pessimistic locking strategies.

42. How do you ensure code quality in large PHP projects?

  • Use static analysis tools like PHPStan or Psalm.
  • Implement CI/CD pipelines with automated testing.

43. How do you handle data exports to CSV and Excel?

  • Use output buffering for large CSV files.
  • Use libraries like PhpSpreadsheet for Excel exports.

44. How do you calculate EMI (Equated Monthly Installments) in PHP?

function calculateEMI($p, $r, $n) {
$r = $r / (12 * 100);
return ($p * $r * pow(1 + $r, $n)) / (pow(1 + $r, $n) - 1);
}

45. How do you secure APIs against replay attacks?

  • Use nonce values and timestamps.
  • Reject requests with expired or reused nonces.

46. How do you implement feature flags in PHP?

  • Store flags in configuration or database.
  • Enable/disable features without requiring code changes.

47. How do you manage user permissions at a granular level?

  • Implement ACL (Access Control List) systems for fine-grained access control.

48. How do you handle real-time data synchronization?

  • Use message brokers like Kafka or RabbitMQ for event streaming.
  • Implement WebSocket-based synchronization.

49. How do you ensure data privacy in shared environments?

  • Encrypt sensitive data at rest and in transit.
  • Implement strict access control policies.

50. How do you calculate API usage analytics?

  • Log API request data (endpoints, user IDs, timestamps).
  • Use analytics tools or custom dashboards to visualize usage.