İngilizce Mülakat Soruları ve Cevapları (PHP Developer)

Question: Can you explain the difference between “include” and “require” in PHP?
(Soru: PHP’de “include” ve “require” arasındaki farkı açıklayabilir misiniz?)

Answer:

  • Both are used to include external files in PHP, but the main difference is in how they handle errors.
  • If a file is not found with “include,” a warning is issued, and the script continues execution. With “require,” it results in a fatal error, and the script stops.
  • Generally, “include” is used when the file being included is not crucial for the script’s functionality, while “require” is used for essential files.
    (Cevap: Her ikisi de PHP’de dış dosyaları dahil etmek için kullanılır, ancak temel fark hataları nasıl işlediklerindedir. “include” ile bir dosya bulunamazsa bir uyarı verilir ve betik çalışmaya devam eder. “require” ile ise bu durum ölümcül bir hataya neden olur ve betik durur. Genellikle, “include” dosyanın betik işlevselliği için önemli olmadığında kullanılırken, “require” önemli dosyalar için kullanılır.)

Question: How does PHP sessions work, and what is the difference between sessions and cookies?
(Soru: PHP oturumları nasıl çalışır ve oturumlar ile çerezler arasındaki fark nedir?)

Answer:

  • PHP sessions are used to store user information on the server between page requests. They rely on a unique session ID stored as a cookie or in the URL.
  • Sessions are server-side storage, while cookies are client-side. Cookies store information on the user’s browser, while sessions store data on the server.
  • Sessions are more secure than cookies because the user cannot directly manipulate the data stored on the server.
    (Cevap: PHP oturumları, sayfa talepleri arasında kullanıcı bilgilerini sunucuda saklamak için kullanılır. Bu, çerezde veya URL’de depolanan benzersiz bir oturum kimliğine dayanır. Oturumlar sunucu taraflı depolama iken, çerezler istemci taraflıdır. Çerezler, bilgileri kullanıcının tarayıcısında saklar, oturumlar ise verileri sunucuda saklar. Oturumlar, kullanıcının sunucuda depolanan verileri doğrudan manipüle edememesi nedeniyle çerezlere göre daha güvenlidir.)

Question: Explain the concept of “prepared statements” in PHP and why they are important for database interactions.
(Soru: PHP’de “prepared statements” kavramını açıklayın ve neden veritabanı etkileşimleri için önemli olduklarını belirtin.)

Answer:

  • Prepared statements are SQL statements that are precompiled and stored on the database server, with placeholders for parameters.
  • They help prevent SQL injection attacks by separating SQL code from user input. User input is treated as data, not executable code.
  • Prepared statements also improve performance, as the database can reuse the precompiled query plan for similar queries, reducing the need for repetitive compilation.
    (Cevap: “Prepared statements” SQL ifadeleridir ve önceden derlenir, veritabanı sunucusunda saklanır ve parametreler için yer tutucular içerir. SQL enjeksiyon saldırılarını engellemeye yardımcı olurlar çünkü kullanıcı girişini SQL kodundan ayırırlar. Kullanıcı girişi, yürütülebilir kod değil, veri olarak ele alınır. Ayrıca, veritabanı benzer sorgular için önceden derlenmiş sorgu planını tekrar kullanabilir, tekrarlayan derleme ihtiyacını azaltarak performansı artırır.)

Question: What is the difference between GET and POST methods in PHP, and when would you use each?
(Soru: PHP’de GET ve POST metodları arasındaki fark nedir ve her birini ne zaman kullanırsınız?)

Answer:

  • GET and POST are both HTTP methods used to send data to the server, but they differ in how they transmit data.
  • GET appends data to the URL, making it visible in the address bar, while POST sends data in the request body, keeping it hidden.
  • Use GET for non-sensitive data and when the data can be cached, and use POST for sensitive or large amounts of data.
    (Cevap: GET ve POST, her ikisi de veriyi sunucuya göndermek için kullanılan HTTP metodlarıdır, ancak veriyi iletim şekillerinde farklılık gösterirler. GET, veriyi URL’ye ekler ve adres çubuğunda görünür kılar, POST ise veriyi istek gövdesinde gönderir ve gizli tutar. GET’i hassas olmayan veriler ve verinin önbelleğe alınabileceği durumlar için, POST’u hassas veya büyük miktarlardaki veriler için kullanın.)

Question: Explain the concept of namespaces in PHP.
(Soru: PHP’de isim alanları (namespaces) kavramını açıklayın.)

Answer:

  • Namespaces in PHP provide a way to encapsulate classes, interfaces, functions, and constants.
  • They help in organizing code by preventing naming conflicts between different parts of a project or between third-party libraries.
  • For example, namespace MyProject; defines a namespace named “MyProject,” and you can then use it to group related code elements.
    (Cevap: PHP’deki isim alanları, sınıfları, arayüzleri, fonksiyonları ve sabitleri kapsüllenmiş bir şekilde sağlar. Farklı projelerin veya üçüncü taraf kütüphanelerin arasında isim çakışmalarını önleyerek kodu düzenlemeye yardımcı olurlar. Örneğin, namespace MyProject; ifadesi “MyProject” adında bir isim alanı tanımlar ve ardından ilgili kod öğelerini gruplamak için kullanılabilirsiniz.)

Question: How do you handle errors in PHP, and what is the purpose of the “try-catch” block?
(Soru: PHP’de hataları nasıl yönetirsiniz ve “try-catch” bloğunun amacı nedir?)

Answer:

  • Errors in PHP can be handled using the try, catch, and finally blocks. The try block contains the code that might throw an exception.
  • If an exception is thrown, the catch block catches it and allows you to handle the error gracefully. The finally block, if used, will execute regardless of whether an exception is thrown or not.
  • Using “try-catch” is crucial for preventing unhandled exceptions that could lead to unexpected behavior in the application.
    (Cevap: PHP’deki hatalar, try, catch ve finally blokları kullanarak yönetilebilir. try bloğu bir istisna fırlatabilecek kodu içerir. Eğer bir istisna fırlatılırsa, catch bloğu bunu yakalar ve hatayı zarif bir şekilde işlemenize olanak tanır. Eğer kullanılıyorsa, finally bloğu istisna fırlatılsın veya fırlatılmasın her durumda çalışacaktır. “try-catch” kullanmak, işlemekte olan istisnalara karşı önlem almak için önemlidir ve bu istisnaların uygulamada beklenmeyen davranışlara yol açmasını engeller.)

Question: Can you explain the difference between “== ” and “===” in PHP?
(Soru: PHP’de “==” ve “===” arasındaki farkı açıklayabilir misiniz?)

Answer:

  • == is a loose comparison operator that checks if the values are equal, converting the types if necessary.
  • === is a strict comparison operator that not only checks if the values are equal but also ensures that the data types are the same.
  • Use == when you want to compare values without considering their types, and use === when both values and types need to match.
    (Cevap: ==, değerlerin eşit olup olmadığını kontrol eden gevşek bir karşılaştırma operatörüdür ve gerekirse tipleri dönüştürür. ===, değerlerin sadece eşit olup olmadığını kontrol etmekle kalmaz, aynı zamanda veri tiplerinin de aynı olmasını sağlar. Değerleri tiplerini dikkate almadan karşılaştırmak istediğinizde == kullanın ve değerlerin ve tiplerin eşleşmesi gerektiğinde === kullanın.)

Question: Explain the concept of autoloading in PHP.
(Soru: PHP’de otomatik yükleme (autoloading) kavramını açıklayın.)

Answer:

  • Autoloading is a mechanism in PHP that automatically includes the necessary class files when they are needed, without requiring explicit include or require statements.
  • It simplifies the development process by automatically loading classes on-demand, reducing the need for manual file inclusion.
  • The spl_autoload_register function is commonly used to register custom autoloaders in PHP.
    (Cevap: Otomatik yükleme, PHP’de ihtiyaç duyulduğunda gerekli sınıf dosyalarını otomatik olarak dahil eden bir mekanizmadır ve açıkça include veya require ifadelerini gerektirmez. Geliştirme sürecini basitleştirir, sınıfları otomatik olarak talep üzerine yükleyerek manuel dosya dahil etme ihtiyacını azaltır. spl_autoload_register fonksiyonu, özel otomatik yükleyicileri PHP’de kaydetmek için yaygın olarak kullanılır.)

Question: How does PHP handle sessions, and what are the advantages of using sessions?
(Soru: PHP nasıl oturumları yönetir ve oturumları kullanmanın avantajları nelerdir?)

Answer:

  • PHP handles sessions by generating a unique session ID for each user, which can be stored in cookies or passed via URLs.
  • Sessions provide a way to persist user data across multiple requests, allowing information to be stored on the server between page loads.
  • Advantages include the ability to maintain user state, store temporary data, and enhance security by preventing the need to pass sensitive information in URLs.
    (Cevap: PHP, her kullanıcı için benzersiz bir oturum kimliği oluşturarak oturumları yönetir ve bu kimlik çerezlerde saklanabilir veya URL’ler aracılığıyla iletilabilir. Oturumlar, kullanıcı verilerini çoklu istekler arasında devamlı kılmak için bir yol sağlar, bilgilerin sayfa yüklemeleri arasında sunucuda saklanmasına olanak tanır. Avantajlar arasında kullanıcı durumunu sürdürme, geçici veri depolama ve hassas bilgileri URL’ler aracılığıyla iletmeme ile güvenliği artırma bulunur.)

Question: What is the purpose of the mysqli and PDO extensions in PHP, and what are the differences between them?
(Soru: PHP’deki mysqli ve PDO uzantılarının amacı nedir ve aralarındaki farklar nelerdir?)

Answer:

  • Both mysqli and PDO are extensions in PHP used for database interaction. They provide a way to connect to databases and execute SQL queries.
  • mysqli is specific to MySQL databases, offering both procedural and object-oriented approaches, while PDO (PHP Data Objects) is a database access layer providing a uniform method of access to multiple databases.
  • One significant difference is that PDO is database-agnostic, making it more flexible for switching between different database systems, while mysqli is MySQL-specific.
    (Cevap: Hem mysqli hem de PDO, veritabanı etkileşimi için kullanılan PHP’deki uzantılardır. Veritabanlarına bağlanmak ve SQL sorgularını çalıştırmak için bir yol sağlarlar. mysqli, MySQL veritabanlarına özgüdür ve hem prosedürel hem de nesne yönelimli yaklaşımları sunar, diğer yandan PDO (PHP Veri Nesneleri), birden fazla veritabanına tek bir yöntemle erişim sağlayan bir veritabanı erişim katmanıdır. Önemli bir fark, PDO‘nun veritabanı bağımsız olmasıdır, bu da farklı veritabanı sistemleri arasında geçiş yapmayı daha esnek hale getirirken, mysqli MySQL’e özgüdür.)

Question: Explain the concept of dependency injection in PHP and why it’s beneficial in object-oriented programming.
(Soru: PHP’de bağımlılık enjeksiyonu (dependency injection) kavramını açıklayın ve neden nesne yönelimli programlamada faydalı olduğunu belirtin.)

Answer:

  • Dependency injection is a design pattern in which a class receives its dependencies from the outside rather than creating them internally.
  • It promotes code reusability, testability, and flexibility by allowing the injection of dependencies, making classes more modular and easier to maintain.
  • In PHP, this often involves passing objects or values through constructor parameters or setter methods.
    (Cevap: Bağımlılık enjeksiyonu, bir sınıfın bağımlılıklarını içsel olarak oluşturmak yerine dışarıdan almasını sağlayan bir tasarım desenidir. Bağımlılıkların enjekte edilmesine izin vererek kodun tekrar kullanılabilirliğini, test edilebilirliğini ve esnekliğini artırır, sınıfları daha modüler ve bakımı daha kolay hale getirir. PHP’de bu genellikle nesneleri veya değerleri yapılandırıcı parametreler veya setter yöntemleri aracılığıyla iletmeyi içerir.)

Question: What is the purpose of the header() function in PHP, and how is it used to handle HTTP headers?
(Soru: PHP’deki header() fonksiyonunun amacı nedir ve nasıl kullanılır, HTTP başlıklarıyla nasıl başa çıkılır?)

Answer:

  • The header() function in PHP is used to send raw HTTP headers to the browser or client.
  • It is commonly used to control the information that the server sends to the browser, such as redirecting the user to another page, setting cookies, or specifying the content type.
  • However, it should be noted that the header() function must be called before any actual output is sent to the browser.
    (Cevap: PHP’deki header() fonksiyonu, ham HTTP başlıklarını tarayıcıya veya istemciye göndermek için kullanılır. Genellikle sunucunun tarayıcıya gönderdiği bilgileri kontrol etmek için kullanılır, kullanıcıyı başka bir sayfaya yönlendirmek, çerezleri ayarlamak veya içerik türünü belirtmek gibi. Ancak dikkat edilmesi gereken bir nokta, header() fonksiyonunun tarayıcıya herhangi bir gerçek çıktı gönderilmeden önce çağrılması gerektiğidir.)

Question: What is the purpose of the $_SESSION variable in PHP, and how is it used for managing user sessions?
(Soru: PHP’deki $_SESSION değişkeninin amacı nedir ve kullanıcı oturumlarını yönetmek için nasıl kullanılır?)

Answer:

  • $_SESSION is a superglobal variable in PHP used to store session variables on the server.
  • It allows data to be persisted across multiple pages during a user’s visit, providing a way to maintain user-specific information.
  • To use it, you start a session with session_start() and then store or retrieve values in the $_SESSION array.
    (Cevap: $_SESSION, PHP’deki oturum değişkenlerini sunucuda saklamak için kullanılan bir süper global değişkendir. Kullanıcının ziyareti sırasında birden çok sayfa boyunca verilerin devam etmesine olanak tanır, kullanıcıya özgü bilgileri sürdürme yolunu sağlar. Kullanmak için session_start() ile bir oturum başlatır ve ardından $_SESSION dizisinde değerleri saklar veya alırsınız.)

Question: Explain the concept of “closures” in PHP and provide an example of how they can be used.
(Soru: PHP’deki “closures” kavramını açıklayın ve nasıl kullanıldığına dair bir örnek verin.)

Answer:

  • Closures, also known as anonymous functions, are functions without a name. They can be assigned to variables, passed as arguments, and returned from other functions.
  • They allow for the creation of functions on the fly, promoting more flexible and concise code.
  • An example of a closure: $multiply = function($x, $y) { return $x * $y; }; echo $multiply(5, 3);
    (Cevap: Closures, adı olmayan fonksiyonlardır ve değişkenlere atanabilir, argüman olarak geçirilebilir ve diğer fonksiyonlardan döndürülebilirler. Hızlıca fonksiyon oluşturmaya olanak tanır, daha esnek ve özlü kodu teşvik eder. Bir closure örneği: $multiply = function($x, $y) { return $x * $y; }; echo $multiply(5, 3);)

Question: What is the purpose of the trait keyword in PHP, and how does it differ from a class or interface?
(Soru: PHP’deki trait anahtar kelimesinin amacı nedir ve bir sınıf veya arayüzden nasıl farklıdır?)

Answer:

  • The trait keyword in PHP is used to group functionality in a fine-grained and consistent way, promoting code reuse.
  • Traits can be viewed as horizontal code inheritance, allowing a developer to use multiple traits in a single class.
  • Unlike classes, traits cannot be instantiated, and unlike interfaces, they can provide actual implementations for methods.
    (Cevap: PHP’deki trait anahtar kelimesi, işlevselliği ince taneli ve tutarlı bir şekilde gruplamak için kullanılır, kodun tekrar kullanımını teşvik eder. Traits, yatay kod mirasını temsil eder ve bir geliştiricinin tek bir sınıfta birden çok trait kullanmasına olanak tanır. Sınıfların aksine, trait’ler örneklenemez ve arayüzlerin aksine, yöntemler için gerçek uygulamalar sağlayabilirler.)

Question: What is the purpose of the use statement in PHP namespaces, and how is it used in practice?
(Soru: PHP isim alanlarındaki use ifadesinin amacı nedir ve pratikte nasıl kullanılır?)

Answer:

  • The use statement in PHP namespaces is used to import classes or namespaces into the current file, allowing you to refer to them with shorter names.
  • It helps in avoiding naming conflicts and makes the code more readable by providing an alias for longer namespace or class names.
  • For example: use MyNamespace\MyClass as CustomName; $obj = new CustomName();
    (Cevap: PHP’deki isim alanlarındaki use ifadesi, sınıfları veya isim alanlarını mevcut dosyaya içe aktarmak için kullanılır, böylece daha kısa isimlerle başvurmanıza olanak tanır. İsim çakışmalarını önlemeye yardımcı olur ve daha uzun isim alanları veya sınıf isimleri için takma ad sağlayarak kodu daha okunabilir hale getirir. Örneğin: use MyNamespace\MyClass as CustomName; $obj = new CustomName();)

Question: What is the difference between array() and [] syntax for creating arrays in PHP?
(Soru: PHP’de diziler oluşturmak için array() ve [] sözdizimi arasındaki fark nedir?)

Answer:

  • Both array() and [] can be used to create arrays in PHP, but [] is a shorthand syntax introduced in PHP 5.4.
  • The shorthand [] syntax is concise and preferred for simplicity, while array() is the traditional syntax.
  • For example: $colors = array("red", "green", "blue"); is equivalent to $colors = ["red", "green", "blue"];
    (Cevap: PHP’de hem array() hem de [] diziler oluşturmak için kullanılabilir, ancak [] PHP 5.4’te tanıtılan kısaltılmış bir sözdizimidir. Kısaltılmış [] sözdizimi özlüdür ve basitlik için tercih edilirken, array() geleneksel sözdizimidir. Örneğin: $colors = array("red", "green", "blue");, $colors = ["red", "green", "blue"]; ile eşdeğerdir.)

Question: How does error handling differ between die(), exit(), and throw in PHP?
(Soru: PHP’de die(), exit(), ve throw arasındaki hata işleme nasıl farklılık gösterir?)

Answer:

  • Both die() and exit() are identical functions in PHP that terminate script execution. They can be used interchangeably.
  • throw is used in the context of exceptions. When an exception is thrown, it can be caught and handled using a try-catch block.
  • die() and exit() are more suitable for general script termination, while throw is specifically designed for exception handling in object-oriented programming.
    (Cevap: die() ve exit() PHP’de betik yürütmesini sonlandıran aynı işlevlerdir ve birbirinin yerine kullanılabilir. throw ise istisnaların bağlamında kullanılır. Bir istisna fırlatıldığında, onu yakalamak ve try-catch bloğu kullanarak işlemek mümkündür. die() ve exit() genel betik sonlandırma için daha uygunken, throw özellikle nesne yönelimli programlamada istisna işleme için tasarlanmıştır.)

Question: What is the significance of the __construct method in PHP classes?
(Soru: PHP sınıflarındaki __construct yönteminin önemi nedir?)

Answer:

  • The __construct method in PHP classes is a special method that is automatically called when an object is created from the class.
  • It is commonly used for initializing object properties or performing setup tasks that need to be done when an object is instantiated.
  • This method allows for more controlled and consistent object initialization.
    (Cevap: PHP sınıflarındaki __construct yöntemi, bir nesne sınıftan oluşturulduğunda otomatik olarak çağrılan özel bir yöntemdir. Genellikle nesne özelliklerini başlatmak veya bir nesne oluşturulduğunda yapılması gereken kurulum görevlerini gerçekleştirmek için kullanılır. Bu yöntem, daha kontrollü ve tutarlı nesne başlatma sağlar.)

Ads Blocker Image Powered by Code Help Pro

Reklam Engelleyici Algılandı!

Reklamları engellemek için uzantı kullandığınızı tespit ettik.

Lütfen bu reklam engelleyiciyi devre dışı bırakarak ya da sitemize izin vererek bize destek olun.

Dikkat: VPN eklentiniz üzerinde de reklam engelleyici olabilir.