PHP Strings Quiz — 20 Questions
PHP Strings Quiz हिंदी में — Quotes, Escape Sequences, Heredoc, strpos, str_replace, str_contains से जुड़े 20 questions। BCA, MCA, BSc students के लिए।
-
PHP में String क्या होती है?
- Characters का एक sequence — letters, numbers, symbols कुछ भी
- सिर्फ letters का collection
- Numbers को text में store करना
- PHP का एक Data Type जो सिर्फ names store करता है
-
PHP में कितने built-in String Functions हैं?
- 100 से ज़्यादा
- सिर्फ 10
- सिर्फ 20
- Exactly 50
-
Double quotes (" ") और Single quotes (' ') में सबसे बड़ा फर्क क्या है?
- Double quotes में variables expand होते हैं, Single में नहीं
- Single quotes में variables expand होते हैं, Double में नहीं
- दोनों में variables expand होते हैं
- दोनों में variables expand नहीं होते
-
$naam = "Rahul"; echo 'Hello $naam!'; — output क्या होगा?
- Hello $naam! (variable expand नहीं होगा)
- Hello Rahul!
- Error आएगी
- Hello !
-
Static text के लिए कौन से quotes prefer किए जाते हैं और क्यों?
- Single quotes — PHP को variable parsing नहीं करनी पड़ती, थोड़े faster हैं
- Double quotes — ज़्यादा readable हैं
- दोनों equal हैं, कोई फर्क नहीं
- Heredoc — सबसे fast है
-
String के अंदर दूसरे quotes लिखने का सही तरीका कौन सा है?
- echo "He said 'Hello'"; — double में single use करो
- echo "He said "Hello""; — same quotes use करो
- echo He said Hello; — quotes ज़रूरी नहीं
- echo (He said Hello); — brackets use करो
-
Escape sequences किस character से शुरू होते हैं?
- Backslash (\)
- Forward slash (/)
- Hash (#)
- Dollar ($)
-
"Price: \$500" — यहाँ \$ का क्या काम है?
- Dollar sign literally print करना (variable की तरह treat न हो)
- Variable $500 को print करना
- String को delete करना
- Escape sequence नहीं है यह
-
Windows file path "C:\\Users\\Rahul" में \\\\ क्यों लिखा?
- एक backslash (\) print करने के लिए — \\\\ = \\
- Path को bold करने के लिए
- यह PHP 8 का नया syntax है
- Error avoid करने के लिए
-
Heredoc और Nowdoc में क्या फर्क है?
- Heredoc में variables expand होते हैं (double quotes जैसा), Nowdoc में नहीं (single quotes जैसा)
- Nowdoc में variables expand होते हैं, Heredoc में नहीं
- दोनों में variables expand होते हैं
- Heredoc PHP 8+ में है, Nowdoc पुराना है
-
Heredoc का closing identifier (EOT) कहाँ लिखना ज़रूरी है?
- Line के एकदम शुरू में — कोई space या tab नहीं
- Line के अंत में
- किसी भी indentation पर
- Function के अंदर ही
-
Heredoc किस काम के लिए सबसे ज़्यादा useful है?
- Long HTML templates और email body जैसी multi-line strings के लिए
- Single line strings के लिए
- Numbers store करने के लिए
- Array बनाने के लिए
-
strpos("Hello World", "World") का output क्या होगा?
- 6 (W की position — index 0 से शुरू)
- 5
- 7
- true
-
strpos() use करते समय सबसे बड़ा trap क्या है?
- Position 0 पर मिले तो false की तरह treat होता है — हमेशा !== false use करो
- यह हमेशा true return करता है
- यह case-sensitive नहीं है
- String नहीं मिलने पर -1 return करता है
-
PHP 8 में str_contains() क्या return करता है?
- true अगर string में substring है, false अगर नहीं है
- Substring की position (integer)
- Substring की count
- हमेशा null
-
File extension check करने के लिए कौन सा PHP 8 function सबसे clean है?
- str_ends_with($file, ".jpg")
- strpos($file, ".jpg")
- strlen($file, ".jpg")
- str_contains_end($file, ".jpg")
-
URL slug बनाने के लिए कौन सा combination सही है?
- strtolower(str_replace(" ", "-", $title))
- strtoupper(str_replace("-", " ", $title))
- trim(str_replace($title, " ", "-"))
- ucwords(str_replace(" ", "_", $title))
-
str_replace() और str_ireplace() में क्या फर्क है?
- str_ireplace() case-insensitive है — "JAVA" और "java" दोनों replace होंगे
- str_replace() case-insensitive है
- दोनों same काम करते हैं
- str_ireplace() सिर्फ PHP 8 में है
-
Form input properly process करने का सही order क्या है?
- trim() → strtolower() → validate — पहले spaces हटाओ, फिर normalize करो
- validate → trim() → strtolower()
- strtolower() → validate → trim()
- validate → strtoupper() → trim()
-
nl2br() function क्या करता है?
- String के \n (newlines) को HTML <br> tag में convert करता है
- HTML tags को remove करता है
- String को new line पर print करता है
- Newlines को spaces में बदलता है