#PHP shorthand if
Explore tagged Tumblr posts
Text
PHP Shorthand if Statements
Learn PHP shorthand if statements (ternary operator) with syntax, examples, use cases, and best practices. Simplify your PHP code using concise conditionals. Mastering PHP Shorthand if Statements (Ternary Operator) PHP offers several ways to write conditional statements, and one of the most concise and powerful is the shorthand if statement, also known as the ternary operator. This feature…
#PHP conditional operator#PHP if else shorthand#PHP shorthand if#PHP ternary operator#shorthand condition in PHP#ternary PHP
0 notes
Text
Filling a PHP array dynamically means that instead of hardcoding the values, you're adding values to the array based on some logic, external input, or data sources. Here's a basic overview and some examples:
1. Create an Empty Array
You can create an empty array using the 'array()' function or the '[]' shorthand.
$dynamicArray = array(); // OR $dynamicArray = [];
2. Add Elements to the Array
You can add elements to an array in various ways:
Append to the array:
$dynamicArray[] = 'value1'; $dynamicArray[] = 'value2';
Add with a specific key:
$dynamicArray['key1'] = 'value1'; $dynamicArray['key2'] = 'value2';
3. Dynamically Filling the Array
Here's how you can fill an array based on various scenarios:
From a database (using PDO for this example)
$stmt = $pdo->query("SELECT value FROM some_table"); while ($row = $stmt->fetch()) { $dynamicArray[] = $row['value']; }
From a form (using POST method as an example):
if (isset($_POST['inputName'])) { $dynamicArray[] = $_POST['inputName']; }
Based on some logic:
for ($i = 0; $i < 10; $i++) { if ($i % 2 == 0) { $dynamicArray[] = $i; } }
This would fill $dynamicArray with even numbers between 0 and 9.
4. Tips and Best Practices
Sanitize external input: Always sanitize and validate data, especially when it's coming from external sources like user input, to ensure security.
Use associative arrays wisely: If you're using string keys, ensure they're unique to avoid overwriting values.
Check existing values: When adding to an array, you may want to check if a value already exists to avoid duplicates.
if (!in_array($value, $dynamicArray)) { $dynamicArray[] = $value; }
Using these methods and principles, you can effectively and dynamically fill a PHP array based on any set of conditions or data sources.
#PHPDevelopment#DynamicArrays#WebDevelopment#ProgrammingTips#DataHandling#PHPArrays#BackEndDevelopment#CodingBestPractices#WebProgramming#DatabaseIntegration#vinhjacker#mageplaza
0 notes
Text
So PHP has introduced what it calls a nullsafe operator. And all it really means, is a shorthand way to write a command that only works if there's something to work on.
as a bonus, the nullsafe is ?, so it looks like this $object?->function(), and I just love it.
do the thing? do the thing little code? it's okay if no
1 note
·
View note
Photo

What’s New in PHP 7.4 (Features, Deprecations, Speed) PHP 7.4 will be released on November 28, 2019. Its features include: Arrow functions for cleaner one-liner functions Preloading to improve performance Typed properties in classes Improved type variance The null coalescing assignment operator as a shorthand FFI for better extension development in PHP Underscores can be used to format numeric values Spread operator in arrays And more, you can read about it here How much of you did this? If you like ,follow us➖➖➖➖➖➖➖➖➖➖➖➖➖➖ | 👍 | ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ | ✏ | Tag a programmer | 🎇 | Best programming knowledge every day ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ | 💬 | Follow @rehman_coding Enjoy! ⠀ #code #programming #developer #coding #wordpress #programmer #webdeveloper #javascript #womenintech #softwaredeveloper #girlswhocode #devlife #worldcode #csharp #learntocode #reactjs #developerlife #frontenddeveloper #angularjs #100daysofcode #peoplewhocode #fullstackdeveloper #vuejs #backenddeveloper #dotnet #mobiledevelopment #womanintech #javascriptdeveloper #javascriptlover #nodejs⠀ https://www.instagram.com/p/B5gHn1oA48G/?igshid=n84jk3gdrhqm
#code#programming#developer#coding#wordpress#programmer#webdeveloper#javascript#womenintech#softwaredeveloper#girlswhocode#devlife#worldcode#csharp#learntocode#reactjs#developerlife#frontenddeveloper#angularjs#100daysofcode#peoplewhocode#fullstackdeveloper#vuejs#backenddeveloper#dotnet#mobiledevelopment#womanintech#javascriptdeveloper#javascriptlover#nodejs
1 note
·
View note
Text
Finding a Magento Developer
When a company sets out to take up new premises, all sorts of people are involved – lawyers, site surveyors, estate agents, and so on. Likewise, in setting up a Magento ecommerce store, many different people are required in distinct but closely interrelated areas.
In this article, we’ll look at how to informatively select your Magento developer, and how best to prepare.
First Things First: What does a Magento developer do?
A Magento developer builds, supports and upgrades and improves a Magento ecommerce site. From building a site from scratch, to integrating an existing inventory from an old site, a Magento developer will be involved in tasks such as:
Installing Magento releases and patches
Building and installing Magento themes
Optimising loading times
Installing and configuring payment options
Integrating Magento with CRMs and PIMs
Performing onsite SEO to improve search rankings
As far as working with a developer goes, even if you are not directly involved in the build yourself, it is still worth understanding the different functions a developer performs. This will help you to effectively communicate with the project lead when discussing your Magento platform.
Magento developers can be split into three basic categories:
Frontend Magento developers spend most of their time working in the app/design folder of Magento. They ensure the customer-facing (hence, frontend) aspect of Magento looks good and provides a seamless customer journey. This extends to making sure the website is responsive and cross-platform compatible so that it works on smartphone as well as tablet devices.
Backend Magento developers focus their energies on coding; making new modules and making sure all the components of the platform are compatible and function to spec. You can think about a backend designer as an engineer who spends the majority of their time in application/code envelope. At a minimum a backend developer will be a proficient in Magento PHP and XML architecture.
Full Stack developers perform both front-end and back-end development. A popular shorthand for this kind of site-building is ‘both-end development’. Though full stack or ‘both-end’ developers can be helpful, for large projects, it is essential to have separate back & front developers. Someone who is able to do both is more likely to be proficient than skilled.
Getting Prepared: Questions to Ask
Before sorting out what questions to ask your development team, you should spend just as much time considering what questions your developer is likely to ask you. If you do your research, initial calls should go much more smoothly, and your key client is much more likely to take you seriously. To that end, you should have at least a general idea of your priorities, timetable, and of course your budget.
Finding your new DeveloperRecommendations
Even in the days of social networking, the best way to source information is often word of mouth. By seeking recommendations internally, from your colleagues or board members, you can often find the perfect hire far more quickly. If you don’t have anyone close to hand to ask, try asking third party service providers. These might be your web designer, accountant, or even your outsourced HR. Failing that, you can always try Linkedin. Assuming you have a reasonably large contact list, it is likely that at least one of your contacts will be able to give you a lead on a reputable Magento expert to use.
Networking via Industry (Magento) Events
Another networking strategy worth utilising is attending Magento Events. Serious, experienced Magento developers are very likely to attend these. Aside from meeting potential new clients, they will want to learn about all the latest news of the platform, and what recent updates mean for their business. In turn, as a relative novice, you might in the process learn something about the platform yourself. As we said earlier, the more you know about Magento, the more you will be able to specify your needs.
The Qualification Test: is your Developer Magento Certified?
Having narrowed down to a short-list, one of the most important things to check is whether or not your developer is Magento certified. There are three different levels of Magento certifications, but all of them guarantee the same thing: that the developer has performed rigorous examinations to determine they are proficient in the platform. To find out if your developer is certified, either ask or look on their website – web developers who have been awarded certification almost always have a badge (like the ones below) on their homepage or landing pages.
Agency vs. Freelance Developer
By now, you should have a fair idea of whether it is an agency (i.e. development team) or a freelancer you need. For the most part, the decision will rest on the scale of the project: you won’t want to hire a single developer for a large project. Only an agency can provide the sort of resources required for a complex project, especially if it involves integrations with existing CRMs or shipping rules.
But there is another thing to consider: even for small projects, such as installing Magento extensions, an agency is still a much safer bet. Though it is likely you will only need one person working on the project, in practice, the developer will have a whole team’s knowledge to draw on, making sure all the steps he has executed are correct, and that he has done everything to the highest standard. For the sake of consistency of quality, it is almost always better to go with an agency.
Summary
Finding a Magento developer can be a struggle even at the least of times, so we hope we’ve made it easier for you. Try to remember though: as smoothly as your site may run after its completion, the likelihood is you will need help again in the future – whether with upgrades, patches, or a complete overhaul of the system. In looking for a Magento developer, taking a long-term view, building long-lasting relationships, will always pay off.
Want to find out more about Magento? Please see our Complete Magento Ecommerce Guide for more details.
1 note
·
View note
Text
Best ways to hire Remote PHP Developers for Your Project
A solid online presence is crucial for the success of any organization in the year 2022. Customer acquisition, customer retention, and customer engagement can all be aided by a professionally designed website.
PHP stands for "Hypertext Preprocessor," which is what it stands for in shorthand. It's a popular open-source language for developing dynamic websites and other types of online apps. PHP's original intent was to facilitate the development of personal websites and HTML scripts.
0 notes
Text
FREE INSPECT READ EBOOK HERE Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader [PDF EBOOK EPUB]

Read it Online Now! Gregg Shorthand (Diamond Jubilee)
Click here to read
https://unlimitedmediaweb.blogspot.com/media12.php?asin=0070246254
Size: 15,014 KB read it here -> https://unlimitedmediaweb.blogspot.com/media90.php?asin=0070246254 - D0WNL0AD PDF Ebook Textbook Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader
Last access: 32747 user
In this pandemic time people can be so bored. To get rid of boredness we can kill our time by doing productive activities including reading books. Here you can read ebooks and novels for free
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader [PDF EBOOK EPUB MOBI Kindle]
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader pdf Read
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader read online
J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader by Gregg Shorthand (Diamond Jubilee) epub
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader pdf inspect free online
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader read ebook
Gregg Shorthand (Diamond Jubilee) pdf
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader amazon reads
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader free Read ebook
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader pdf free
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader pdf
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader epub Read
Gregg Shorthand (Diamond Jubilee) by J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader online
J.R. Gregg, Louis A. Leslie, Charles E. Zoubek, Charles Rader
0 notes
Text
Unix Regex Cheat Sheet

Grep Regex Cheat Sheet
Perl Regex Cheat Sheet Pdf
Unix Regex Cheat Sheet Download
Unix Regex Cheat Sheet Example
A regular expression, regex or regexp is a sequence of characters that define a search pattern. Usually such patterns are used by string searching algorithms for 'find' or 'find and replace' operations on strings, or for input validation.
Cheat Sheet This cheat sheet is intended to be a quick reminder for the main concepts involved in using regular expressions and assumes you already understand their usage. If you are new to regular expressions we strongly suggest you work through the Regular Expressions tutorial from the beginning.
Regular Expressions Cheat Sheet by DaveChild - Cheatography.com Created Date: 4237Z. Name Command; Insert string to the begining of lines: sed -i 's/^/head /g' my-file: Insert string to the end of lines: sed -i 's/$/ tail/g' my-file: Add content after nth line.
characters — what to seek
ring matches ring, springboard, ringtone, etc.
. matches almost any character
h.o matches hoo, h2o, h/o, etc.
Use to search for these special characters:
( ^ $ . | ? * + ( ) ( )
ring? matches ring?
(quiet) matches (quiet)
c:windows matches c:windows
alternatives — | (OR)
cat|dog match cat or dog
order matters if short alternative is part of longer
id|identity matches id or identity
regex engine is 'eager', stops comparing as soon as 1st alternative matches
identity|id matches id or identity
order longer to shorter when alternatives overlap
(To match whole words, see scope and groups.)
character classes — (allowed) or (^NOT allowed)
(aeiou) match any vowel
(^aeiou) match a NON vowel

r(iau)ng match ring, wrangle, sprung, etc.
gr(ae)y match gray or grey
(a-zA-Z0-9) match any letter or digit
(In ( ) always escape . ) and sometimes ^ - .)
shorthand classes
w 'word' character (letter, digit, or underscore)
d digit
s whitespace (space, tab, vtab, newline)
W, D, or S, (NOT word, digit, or whitespace)
(DS) means not digit OR whitespace, both match
(^ds) disallow digit AND whitespace
occurrences — ? * + (n) (n,) (n,n)
? 0 or 1
colou?r match color or colour
* 0 or more
(BW)ill(ieamy's)* match Bill, Willy, William's etc.
+ 1 or more
(a-zA-Z)+ match 1 or more letters
(n) require n occurrences
d(3)-d(2)-d(4) match a SSN
(n,) require n or more
(a-zA-Z)(2,) 2 or more letters
Deezer ariana grande. Ariana Grande 10257966 fans Grammy winning, multi-platinum recording artist and international superstar, Ariana Grande, is the first artist to achieve the top three Billboard Hot 100 spots since The Beatles in 1964 with “7 Rings,” “Break Up With Your Girlfriend, I'm Bored,” and “Thank U, Next.”. Ariana Grande 10270075 fans Grammy winning, multi-platinum recording artist and international superstar, Ariana Grande, is the first artist to achieve the top three Billboard Hot 100 spots since The Beatles in 1964 with “7 Rings,” “Break Up With Your Girlfriend, I'm Bored,” and “Thank U, Next.”.
(n,m) require n - m
(a-z)w(1,7) match a UW NetID
* greedy versus *? lazy
* + and (n,) are greedy — match as much as possible
<.+> finds 1 big match in <b>bold</b>
*? +? and (n,)? are lazy — match as little as possible
<.+?> finds 2 matches in <b>bold</b>
comments — (?#comment)
(?#year)(19|20)dd embedded comment
(?x)(19|20)dd #year free spacing & EOL comment
(see modifiers)
scope — b B ^ $
b 'word' edge (next to non 'word' character)
bring word starts with 'ring', ex ringtone
ringb word ends with 'ring', ex spring
b9b match single digit 9, not 19, 91, 99, etc.
b(a-zA-Z)(6)b match 6-letter words
B NOT word edge
BringB match springs and wringer Body model sketch.
^ start of string $ end of string
^d*$ entire string must be digits
^(a-zA-Z)(4,20)$ string must have 4-20 letters
^(A-Z) string must begin with capital letter
(.!?'))$ string must end with terminal puncutation
Chrome we. Discover great apps, games, extensions and themes for Google Chrome.
groups — ( )
(in|out)put match input or output
d(5)(-d(4))? US zip code ('+ 4' optional)
Locate all PHP input variables:
$_(GET|POST|REQUEST|COOKIE|SESSION|SERVER)(.+)
NB: parser tries EACH alternative if match fails after group. Can lead to catastrophic backtracking.
back references — n
each ( ) creates a numbered 'back reference'
(to) (be) or not 1 2 match to be or not to be
((^s))1(2) match non-space, then same twice more aaa, ..
b(w+)s+1b match doubled words
non-capturing group — (?: ) prevent back reference
on(?:click|load) is faster than on(click|load)
use non-capturing or atomic groups when possible
atomic groups — (?>a|b) (no capture, no backtrack)
(?>red|green|blue)
faster than non-capturing
alternatives parsed left to right without return
(?>id|identity)b matches id, but not identity
'id' matches, but 'b' fails after atomic group, parser doesn't backtrack into group to retry 'identity'
If alternatives overlap, order longer to shorter.
lookahead — (?= ) (?! ) lookbehind — (?<= ) (?<! )
bw+?(?=ingb) match warbling, string, fishing, ..
b(?!w+ingb)w+b words NOT ending in 'ing'
Grep Regex Cheat Sheet
(?<=bpre).*?b match pretend, present, prefix, ..
bw(3)(?<!pre)w*?b words NOT starting with 'pre'
(lookbehind needs 3 chars, w(3), to compare w/'pre')
bw+(?<!ing)b match words NOT ending in 'ing'
(see LOOKAROUND notes below)
if-then-else — (?ifthen|else)
match 'Mr.' or 'Ms.' if word 'her' is later in string
M(?(?=.*?bherb)s|r). lookahead for word 'her'
(requires lookaround for IF condition)
modifiers — i s m x
ignore case, single-line, multi-line, free spacing
(?i)(a-z)*(?-i) ignore case ON / OFF
(?s).*(?-s) match multiple lines (causes . to match newline)
(?m)^.*;$(?-m)^ & $ match lines not whole string
(?x) #free-spacing mode, this EOL comment ignored
d(3) #3 digits (new line but same pattern)
-d(4) #literal hyphen, then 4 digits
(?-x) (?#free-spacing mode OFF)
/regex/ismx modify mode for entire string
A few examples:
(?s)<p(?(?=s) .*?)>(.*?)</p> span multiple lines
(?s)<p(?(?=s) .*?)>(.*?)</p> locate opening '<p'
(?s)<p(?(?=s) .*?)>(.*?)</p> create an if-then-else
(?s)<p(?(?=s) .*?)>(.*?)</p> lookahead for a whitespace character
(?s)<p(?(?=s) .*?)>(.*?)</p> if found, attempt lazy match of any characters until ..
(?s)<p(?(?=s) .*?)>(.*?)</p> closing angle brace
(?s)<p(?(?=s) .*?)>(.*?)</p> capture lazy match of all characters until ..
(?s)<p(?(?=s) .*?)>(.*?)</p> closing '</p>'
The lookahead prevents matches on PRE, PARAM, and PROGRESS tags by only allowing more characters in the opening tag if P is followed by whitespace. Otherwise, '>' must follow '<p'.
LOOKAROUND notes
(?= ) if you can find ahead
(?! ) if you can NOT find ahead
(?<= ) if you can find behind
(?<! ) if you can NOT find behind
convert Firstname Lastname to Lastname, Firstname (& visa versa)
Pattern below uses lookahead to capture everything up to a space, characters, and a newline. The 2nd capture group collects the characters between the space and the newline. This allows for any number of names/initials prior to lastname, provided lastname is at the end of the line.
Find: (.*)(?= .*n) (.*)n
Repl: 2, 1n — insert 2nd capture (lastname) in front of first capture (all preceding names/initials)
Reverse the conversion.
Find: (.*?), (.*?)n — group 1 gets everything up to ', ' — group 2 gets everything after ', '
Repl: 2 1n
lookaround groups are non-capturing
If you need to capture the characters that match the lookaround condition, you can insert a capture group inside the lookaround.
(?=(sometext)) the inner () captures the lookahead
This would NOT work: ((?=sometext)) Because lookaround groups are zero-width, the outer () capture nothing.
lookaround groups are zero-width
They establish a condition for a match, but are not part of it.
Compare these patterns: re?d vs r(?=e)d
re?d — match an 'r', an optional 'e', then 'd' — matches red or rd
r(?=e)d — match 'r' (IF FOLLOWED BY 'e') then see if 'd' comes after 'r'
Perl Regex Cheat Sheet Pdf
The lookahead seeks 'e' only for the sake of matching 'r'.
Because the lookahead condition is ZERO-width, the expression is logically impossible.
It requires the 2nd character to be both 'e' and 'd'.
For looking ahead, 'e' must follow 'r'.
For matching, 'd' must follow 'r'.
fixed-width lookbehind
Most regex engines depend on knowing the width of lookbehind patterns. Ex: (?<=h1) or (?<=w(4)) look behind for 'h1' or for 4 'word' characters.
This limits lookbehind patterns when matching HTML tags, since the width of tag names and their potential attributes can't be known in advance.
variable-width lookbehind
.NET and JGSoft support variable-width lookbehind patterns. Ex: (?<=w+) look behind for 1 or more word characters. The first few examples below rely on this ability.
Lookaround groups define the context for a match. Here, we're seeking .* ie., 0 or more characters. A positive lookbehind group (?<= . . . ) preceeds. A positive lookahead group (?= . . . ) follows. These set the boundaries of the match this way:
(?<=<(w+)>).*(?=</1>) look behind current location
(?<=<(w+)>).*(?=</1>) for < > surrounding ..
(?<=<(w+)>).*(?=</1>) one or more 'word' characters. The ( ) create a capture group to preserve the name of the presumed tag: DIV, H1, P, A, etc.
(?<=<(w+)>).*(?=</1>) match anything until
(?<=<(w+)>).*(?=</1>) looking ahead from the current character
(?<=<(w+)>).*(?=</1>) these characters surround
(?<=<(w+)>).*(?=</1>) the contents of the first capture group
In other words, advance along string until an opening HTML tag preceeds. Match chars until its closing HTML tag follows. The tags themselves are not matched, only the text between them.
Unix Regex Cheat Sheet Download
To span multiple lines, use the (?s) modifier. (?s)(?<=<cite>).*(?=</cite>) Match <cite> tag contents, regardless of line breaks.
As in example above, the first group (w+) captures the presumed tag name, then an optional space and other characters ?.*? allow for attributes before the closing >.
class='.*?bredb.*?' this new part looks for class=' and red and ' somewhere in the opening tag
b ensures 'red' is a single word
.*? allow for other characters on either side of 'red' so pattern matches class='red' and class='blue red green' etc.
Here, the first group captures only the tag name. The tag's potential attributes are outside the group.
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> set ignore case ON
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> find an opening tag by matching 1 letter after <
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> then match 0 or more letters or digits
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> make this tag a capture group
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> match 0 or more characters that aren't > — this allows attributes in opening tag
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> match the presumed end of the opening tag
(NB: This markup <a> would end the match early. Doesn't matter here. Subsequent < pulls match to closing tag. But if you attempted to match only the opening tag, it might be truncated in rare cases.)
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> lazy match of all of tag's contents
(?i)<((a-z)(a-z0-9)*)(^>)*>.*?</1> match the closing tag — 1 refers to first capture group
The IF condition can be set by a backreference (as here) or by a lookaround group.
(()?d(3) optional group ( )? matches '(' prior to 3-digit area code d(3) — group creates back reference #1
(?(1)) ?|(-/ .)) (1) refers to group 1, so if '(' exists, match ')' followed by optional space, else match one of these: '- / . '
d(3)(- .)d(4) rest of phone number
Unix Regex Cheat Sheet Example
For a quick overview: http://www.codeproject.com/KB/dotnet/regextutorial.aspx.
For a good tutorial: http://www.regular-expressions.info.
We would like to show you a description here but the site won’t allow us. Walmart insurance copay.

0 notes
Text
For literal years I worked with a database class that both required you to manually write SQL and didn’t provide any options for when your dataset was larger than the amount of memory currently available to your PHP process.
This is ridiculous because it wasn’t any easier than just using the default PDO class && it removed the ability to iterate over the results of a large query by loading a single result into memory at a time. A default feature of PDO.
One of the first things I did when I was writing the “thumb” class at the heart of all of my modern PHP work was to say “hey, PDO does some pretty great things as far as the actual database handling, let’s not fuck with that and instead just staple some actually useful functions/shorthand onto the side of it.”
Thumb is 186 lines long and 133 of those lines are the functions for exporting and importing from files.
The actual database handling part of the class is 50 lines long and consists of three functions.
__construct() which automates the settings and attributes of the PDO connection, allowing you to load from a config file or provided array. query() which is the main function that prepares the the statement and returns a PDO transaction object on success or a false bool & rollback if an error occurs.
binder() which can probably be removed since I never use it, but allows the PDO object to cast integers as integers so that I could theoretically prepare offsets and limits the way I do values. But functionally, I never allow direct user input for offsets and limits so it isn’t something I really need or use. What I do instead is have my code evaluate what it “thinks” it is, and then manually provide a new copy of that so we can be absolutely sure of its typing and that it doesn’t have any extra data following along.
0 notes
Text
17 JavaScript Methods And Shorthands
17 JavaScript Methods And Shorthands #javascript #php #html #css #webdeveloper #coding #programming #developer #webdevelopment #programmer #html5 #webdev #java #coder #programmers #css3 #computerscience #software #softwaredeveloper
In this article I will talk about JavaScript method and shorthands you should know to be more efficient developer. JavaScript important methods you must know Some important and fundamentals method you should know as you’ll use them frequently in your projects. slice(): The slice() method returns a shallow copy of a portion of an array into a new array object selected and end represent from…
View On WordPress
#javascript#javascriptdev#javascriptfunction#javascriptglobalfunctions#javascriptstatement#javascripttutorial#js#method#shorthands
0 notes
Photo

PHP Conditional Statements: Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this. In PHP we have the following conditional statements: if statement - executes some code if one condition is true if...else statement - executes some code if a condition is true and another code if that condition is false if...elseif...else statement - executes different codes for more than two conditions Ternary Operators In addition to all this conditional statements, PHP provides a shorthand way of writing if…else, called Ternary Operators. The statement uses a question mark (?) and a colon (:) and takes three operands: a condition to check, a result for TRUE and a result for FALSE. #php #code #coding #phpdevelooer #developer #afgprogrammer #codesnippet #phpprogramming https://www.instagram.com/p/CLRhNqpjQyn/?igshid=msos8smu9fd3
0 notes
Text
Online education companies in lucknow
IT sector has brought a lot of changes and innovations into various fields even for education system. Many institutions were using information systems for managing their records both academic and non-academic matters. one significant perspective that is influenced development in instructive establishments is the educating and learning area. The presentation of e-learning stages has decreased a great deal of difficulty related to instructing in different establishments. Instructors think that its simple to share and disperse learning materials to understudies. E-learning includes obtaining of information and aptitudes utilizing electronic advances, for example, PC and web. It offers a chance to access and offer learning materials in different arrangements, for example, word record, PDF, PPT slideshows, sound and recordings for exhibit, talk and informing gatherings for connections with teachers or different students.
Five most important factor :
A. Concept of e-learning 1) What is e-learning? E-Learning enables you to learn anywhere and anytime irrespective of geographical locations. In 1840s, Isaac Pitman usually teaches his students shorthand by correspondence. Ashayein came up with good Online education companies in lucknow also adopted e-learning platforms to educate, train their employees and good quality of videos and methodology. This has given teachers the opportunities to improve their technical knowledge and skills towards achieving organizational objectives.
2) Benefits of e-learning i) Comprehensive ii) Less Expensive iii) Updating is Easy iv) Self Directed Convenient v) Quick Moves faster vi) Easily manageable for large group pf students vii) Dynamic Interactive
B. Learning Management System Learning the board framework (LMS) is an application program (framework) created to oversee online courses, share learning materials. LMSs are a greater amount of web-based interfaces created utilizing various stages or projects, for example, PHP, java or .Net.
4 useful advantages of LMS 1) Motivates learner 2) You can put your query during session 3) Access to learning materials 4) Reusability
E-learning is a stage that gives organizations methods for improving educating and learning exercises. It upgrades understudies educator relationship and furnish understudies with methods for cooperations among themselves. This paper featured the significance of e-learning and examination of e learning organizations and furthermore depicts extent of e learning in India.
C. e-learning in Lucknow Nowadays, at this time where the corona virus has destroyed everything from Teiji and due to the growing Indian economy, India has a chance to become the heart of e-learning programs. Ashayein has also brought this Online education companies in lucknow with the same hope so that all the students who are here have no problem. The scope of e-learning in India is very wide, with many e-learning companies moving towards providing services and the focus of Asha is also on this. While it is not really the case that e-learning only gives more value to the process, distance is independent of the factor. In India, the e-learning landscape is still growing and is at the experimental level, work is still going on. The traditional mindset is changing, people are now moving like Online education companies in lucknow and this change is necessary.
D. Online education scope and growth in Lucknow The scope of open distance education in India is very broad indeed, this epidemic of online classes has come from the body of Kovid-19. Ashayein is bringing an e-learning video of Maths and Classes. Thus, the reach of e-learning in Lucknow has increased from adults to youth.
0 notes
Text
Introducing Alpine.js: A Tiny JavaScript Framework | ArkssTech

Introducing Alpine.js: A Tiny JavaScript Framework Like most developers, I have a bad tendency to over-complicate my workflow, especially if there’s some new hotness on the horizon. Why use CSS when you can use CSS-in-JS? Why use Grunt when you can use Gulp? Why use Gulp when you can use Webpack? Why use a traditional CMS when you can go headless? Every so often though, the new-hotness makes life simpler. Recently, the rise of utility based tools like Tailwind CSS have done this for CSS, and now Alpine.js promises something similar for JavaScript. In this article, we’re going to take a closer look at Alpine.js and how it can replace JQuery or larger JavaScript libraries to build interactive websites. If you regularly build sites that require a sprinkling on Javascript to alter the UI based on some user interaction, then this article is for you. Throughout the article, I refer to Vue.js, but don’t worry if you have no experience of Vue — that is not required. In fact, part of what makes Alpine.js great is that you barely need to know any JavaScript at all. Now, let’s get started. What Is Alpine.js? According to project author Caleb Porzio: “Alpine.js offers you the reactive and declarative nature of big frameworks like Vue or React at a much lower cost. You get to keep your DOM, and sprinkle in behavior as you see fit.” Let’s unpack that a bit. Let’s consider a basic UI pattern like Tabs. Our ultimate goal is that when a user clicks on a tab, the tab contents displays. If we come from a PHP background, we could easily achieve this server side. But the page refresh on every tab click isn’t very ‘reactive’. To create a better experience over the years, developers have reached for jQuery and/or Bootstrap. In that situation, we create an event listener on the tab, and when a user clicks, the event fires and we tell the browser what to do. See the Pen Showing / hiding with jQuery by Phil on CodePen. See the Pen Showing / hiding with jQuery by Phil on CodePen. That works. But this style of coding where we tell the browser exactly what to do (imperative coding) quickly gets us in a mess. Imagine if we wanted to disable the button after it has been clicked, or wanted to change the background color of the page. We’d quickly get into some serious spaghetti code. Developers have solved this issue by reaching for frameworks like Vue, Angular and React. These frameworks allow us to write cleaner code by utilizing the virtual DOM: a kind of mirror of the UI stored in the browser memory. The result is that when you ‘hide’ a DOM element (like a tab) in one of these frameworks; it doesn’t add a display:none; style attribute, but instead it literally disappears from the ‘real’ DOM. This allows us to write more declarative code that is cleaner and easier to read. But this is at a cost. Typically, the bundle size of these frameworks is large and for those coming from a jQuery background, the learning curve feels incredibly steep. Especially when all you want to do is toggle tabs! And that is where Alpine.js steps in. WANT TO BUILD YOUR BUSINESS APP IN LARAVEL FRAMEWORK? ARKSSTECH, AGILE SOFTWARE DEVELOPMENT COMPANY OFFERS EXPERIENCED LARAVEL APP DEVELOPERS & TO HIRE LARAVEL DEVELOPERS FOR STARTUPS AND SMES. RENT A CODER TODAY!! Like Vue and React, Alpine.js allows us to write declarative code but it uses the “real” DOM; amending the contents and attributes of the same nodes that you and I might edit when we crack open a text editor or dev-tools. As a result, you can lose the filesize, wizardry and cognitive-load of larger framework but retain the declarative programming methodology. And you get this with no bundler, no build process and no script tag. Just load 6kb of Alpine.js and you’re away! Alpine.js JQuery Vue.js React + React DOM Coding style Declarative Imperative Declarative Declarative Requires bundler No No No Yes Filesize (GZipped, minified) 6.4kb 30kb 32kb 5kb + 36kb Dev-Tools No No Yes Yes WANT TO BUILD YOUR BUSINESS APP IN LARAVEL FRAMEWORK? ARKSSTECH, AGILE SOFTWARE DEVELOPMENT COMPANY OFFERS EXPERIENCED LARAVEL APP DEVELOPERS & TO HIRE LARAVEL DEVELOPERS FOR STARTUPS AND SMES. RENT A CODER TODAY!! When Should I Reach For Alpine? For me, Alpine’s strength is in the ease of DOM manipulation. Think of those things you used out of the box with Bootstrap, Alpine.js is great for them. Examples would be: Showing and hiding DOM nodes under certain conditions, Binding user input, Listening for events and altering the UI accordingly, Appending classes. You can also use Alpine.js for templating if your data is available in JSON, but let’s save that for another day. When Should I Look Elsewhere? If you’re fetching data, or need to carry out additional functions like validation or storing data, you should probably look elsewhere. Larger frameworks also come with dev-tools which can be invaluable when building larger UIs. From jQuery To Vue To Alpine Two years ago, Sarah Drasner posted an article on Smashing Magazine, “Replacing jQuery With Vue.js: No Build Step Necessary,” about how Vue could replace jQuery for many projects. That article started me on a journey which led me to use Vue almost every time I build a user interface. Today, we are going to recreate some of her examples with Alpine, which should illustrate its advantages over both jQuery and Vue in certain use cases. Alpine’s syntax is almost entirely lifted from Vue.js. In total, there are 13 directives. We’ll cover most of them in the following examples. Getting Started Like Vue and jQuery, no build process is required. Unlike Vue, Alpine it initializes itself, so there’s no need to create a new instance. Just load Alpine and you’re good to go. The scope of any given component is declared using the x-data directive. This kicks things off and sets some default values if required: ... Capturing User Inputs x-model allow us to keep any input element in sync with the values set using x-data. In the following example, we set the name value to an empty string (within the form tag). Using x-model, we bind this value to the input field. By using x-text, we inject the value into the innerText of the paragraph element. This highlights the key differences with Alpine.js and both jQuery and Vue.js. Updating the paragraph tag in jQuery would require us to listen for specific events (keyup?), explicitly identify the node we wish to update and the changes we wish to make. Alpine’s syntax on the other hand, just specifies what should happen. This is what is meant by declarative programming. Updating the paragraph in Vue while simple, would require a new script tag: new Vue({ el: '#app', data: { name: '' } }); While this might not seem like the end of the world, it highlights the first major gain with Alpine. There is no context-switching. Everything is done right there in the HTML — no need for any additional JavaScript. Click Events, Boolean Attributes And Toggling Classes Like with Vue, : serves as a shorthand for x-bind (which binds attributes) and @ is shorthand for x-on (which indicates that Alpine should listen for events). In the following example, we instantiate a new component using x-data, and set the default value of show to be false. When the button is clicked, we toggle the value of show. When this value is true, we instruct Alpine to append the aria-expanded attribute. x-bind works differently for classes: we pass in object where the key is the class-name (active in our case) and the value is a boolean expression (show). WANT TO BUILD YOUR BUSINESS APP IN LARAVEL FRAMEWORK? ARKSSTECH, AGILE SOFTWARE DEVELOPMENT COMPANY OFFERS EXPERIENCED LARAVEL APP DEVELOPERS & TO HIRE LARAVEL DEVELOPERS FOR STARTUPS AND SMES. RENT A CODER TODAY!! Hiding And Showing The syntax showing and hiding is almost identical to Vue. This will set a given DOM node to display:none. If you need to remove a DOM element completely, x-if can be used. However, because Alpine.js doesn’t use the Virtual DOM, x-if can only be used on a (tag that wraps the element you wish to hide). Magic Properties In addition to the above directives, three Magic Properties provide some additional functionality. All of these will be familiar to anyone working in Vue.js. $el fetches the root component (the thing with the x-data attribute); $refs allows you to grab a DOM element; $nextTick ensures expressions are only executed once Alpine has done its thing; $event can be used to capture a nature browser event. Let’s Build Something Useful It’s time to build something for the real world. In the interests of brevity I’m going to use Bootstrap for styles, but use Alpine.js for all the JavaScript. The page we’re building is a simple landing page with a contact form displayed inside a modal that submits to some form handler and displays a nice success message. Just the sort of thing a client might ask for and expect pronto!
Initial view (Large preview)
Modal open (Large preview)
Success message (Large preview) Note: You can view the original markup here. WANT TO BUILD YOUR BUSINESS APP IN LARAVEL FRAMEWORK? ARKSSTECH, AGILE SOFTWARE DEVELOPMENT COMPANY OFFERS EXPERIENCED LARAVEL APP DEVELOPERS & TO HIRE LARAVEL DEVELOPERS FOR STARTUPS AND SMES. RENT A CODER TODAY!! To make this work, we could add jQuery and Bootstrap.js, but that is quite a bit of overhead for not a lot of functionality. We could probably write it in Vanilla JS, but who wants to do that? Let’s make it work with Alpine.js instead. First, let’s set a scope and some initial values: Now, let’s make our button set the showModal value to true: Get in touch When showModal is true, we need to display the modal and add some classes: Let’s bind the input values to Alpine: And disable the ‘Submit’ button, until those values are set: Submit Finally, let’s send data to some kind of asynchronous function, and hide the modal when we’re done: Submit And that’s about it! Just Enough JavaScript When building websites, I’m increasingly trying to ask myself what would be “just enough JavaScript”? When building a sophisticated web application, that might well be React. But when building a marketing site, or something similar, Alpine.js feels like enough. (And even if it’s not, given the similar syntax, switching to Vue.js takes no time at all). It’s incredibly easy to use (especially if you’ve never used VueJS). It’s tiny ( There are more advanced features that aren’t included in this article and Caleb is constantly adding new features. If you want to find out more, take a look at the official docs on Github. WANT TO BUILD YOUR BUSINESS APP IN LARAVEL FRAMEWORK? ARKSSTECH, AGILE SOFTWARE DEVELOPMENT COMPANY OFFERS EXPERIENCED LARAVEL APP DEVELOPERS & TO HIRE LARAVEL DEVELOPERS FOR STARTUPS AND SMES. RENT A CODER TODAY!! Read the full article
#bestbrowsersforwebdesign#designsystems#webdesignbrowsers#webdesigncomponents#webdesigntools#webdesignworkflow
0 notes
Text
How to install and use NPM package browser-sync
Introduction #Introduction
Browsersync is a Node.js module. It provides a platform for fast network applications.
It is a Time saving synchronized browser testing.
In short, it creates a server like http://localhost:3000/ and watches the file changes. When our specified files change it auto-reload the browser and show these changes instantly.
It saves our time to refresh the browser, while development.
How? Let’s keep with me to see how to install and use the NPM package browser-sync?
Crate Example Project #Crate Example Project
To test the browser-sync we need an example project. So, Let’s create a simple NPM project.
Step 1: Create a Directory
Open the terminal window and navigate to the location where you want to create your project.
I’m creating the directory es6-tutorials in location D:\xampp\htdocs\reactjs\
E.g.
D: λ cd D:\xampp\htdocs\reactjs\ D:\xampp\htdocs\reactjs\ λ mkdir es6-tutorials D:\xampp\htdocs\reactjs\ λ cd es6-tutorials D:\xampp\htdocs\reactjs\es6-tutorials
Step 2: Initialise NPM Project
Initialize the project with command npm init.
Type command npm init and simply press enter keys.
E.g.
D:\xampp\htdocs\reactjs\es6-tutorials λ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg>` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. package name: (es6-tutorials) version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: license: (MIT) About to write to D:\xampp\htdocs\reactjs\es6-tutorials\package.json: { "name": "es6-tutorials", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Mahesh Waghmare", "license": "MIT" } Is this OK? (yes)
Here, The new file package.json is added into our project directory D:\xampp\htdocs\reactjs\es6-tutorials\.
The file package.json contain all the information about our NPM project.
OR
You can also use the shorthand method npm init --yes which does not ask you any questions and auto-fill all the default values and create the package.json file.
I have not npm init –yes before because, If you are fresher then you need to know which things NPM ask to create the package.json file.
Step 3: Create a file index.html
Create a simple index.html file which we use for testing the browser-sync.
Create file index.html and add the below code within it.
<!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> <script type="text/javascript"> console.log( 'ok' ); </script> </body> </html>
Installation #Installation
Now, our sample project is ready to install and test the NPM package browser-sync.
If you know a little bit about the NPM packages then you know the installing packages locally for the specific project or globally to use it in any project.
Let’s check both installations.
Local Install #Local Install
This is the preferred way to use Browsersync – installing it locally for each project. This way the dependency can be added to your package.json file and everyone on your team.
$ npm install browser-sync
Global Install #Global Install
If you would like to run Browsersync from the command line in any directory, it can be installed globally with the following command.
The command installation command is the same as above, We have just added -g which indicates that install the package in the global scope.
npm install -g browser-sync
I’m going to install it globally.
E.g.
D:\xampp\htdocs\reactjs\es6-tutorials λ npm install -g browser-sync C:\Users\intel\AppData\Roaming\npm\browser-sync -> C:\Users\intel\AppData\Roaming\npm\node_modules\browser-sync\dist\bin.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\browser-sync\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + [email protected] updated 7 packages in 98.767s
Here, The NPM package browser-sync is successfully installed with version 2.26.7
Using browser-sync #Using browser-sync
Now open terminal and type command browser-sync start --server --files "index.html".
E.g.
D:\xampp\htdocs\reactjs\es6-tutorials λ browser-sync start --server --files "index.html" [Browsersync] Access URLs: ------------------------------------ Local: http://localhost:3000 External: http://192.168.0.6:3000 ------------------------------------ UI: http://localhost:3001 UI External: http://localhost:3001 ------------------------------------ [Browsersync] Serving files from: ./ [Browsersync] Watching files...
Here, The command itself describes all the things.
It starts the server on local http://localhost:3000 and checks the changes from file index.html file.
The browser window auto-open with the location http://localhost:3000. If not then open the browser and visit http://localhost:3000 and open the console tab.
It shows the ok in the console.
You can see something like the below screenshot.
browser-sync first visit
Now, Open the index.html file and change string ok with Hello World and save the file.
Now you see the browser auto-reload and it shows the string Hello World in the console.
E.g.
browser after saving the index.html file.
Also, If you notice in our terminal it shows the strings.
.. [Browsersync] Reloading Browsers... [Browsersync] Reloading Browsers...
Which means that our browser is reloaded for each file save.
e.g.
Terminal Window
Example Commands #Example Commands
Below are some example commands for reference.
Watch all the CSS files.
λ browser-sync start --server --files "*.css"
Start a server from the app directory, watching all files
λ browser-sync start --server 'app' --files 'app'
As above, but with version >= 2.23.0
λ browser-sync app -w
Start a server from the app & .tmp directories (shorthand) (requires 2.12.1)
λ browser-sync start -s 'app' '.tmp' -f 'app' '.tmp'
As above, but with version >= 2.23.0
λ browser-sync 'app' '.tmp' -w
Proxy a PHP app + serve static files & watch them
λ browser-sync start --proxy 'mylocal.dev' --serveStatic 'public' --files 'public'
As above, but with version >= 2.23.0
λ browser-sync 'http://mylocal.dev' 'public' -w
Start Browsersync from a config file
λ browser-sync start --config 'conf/browser-sync.js'
Start Browsersync from a config file with overriding flags
λ browser-sync start --config 'conf/browser-sync.js' --port 4000
How to install and use NPM package browser-sync? Let’s learn about it.
Tweet
from WordPress http://bit.ly/36xAW9N via IFTTT
0 notes
Text
300+ TOP JAVASCRIPT Interview Questions and Answers
JAVA SCRIPT Interview Questions for freshers experienced :
1. What is JavaScript? JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems. 2. How is JavaScript different from Java? JavaScript was developed by Brendan Eich of Netscape; Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for different audiences. Java is a full-fledged programming language tailored for network computing; it includes hundreds of its own objects, including objects for creating user interfaces that appear in Java applets (in Web browsers) or standalone Java applications. In contrast, JavaScript relies on whatever environment it’s operating in for the user interface, such as a Web document’s form elements. JavaScript was initially called LiveScript at Netscape while it was under development. A licensing deal between Netscape and Sun at the last minute let Netscape plug the “Java” name into the name of its scripting language. Programmers use entirely different tools for Java and JavaScript. It is also not uncommon for a programmer of one language to be ignorant of the other. The two languages don’t rely on each other and are intended for different purposes. In some ways, the “Java” name on JavaScript has confused the world’s understanding of the differences between the two. On the other hand, JavaScript is much easier to learn than Java and can offer a gentle introduction for newcomers who want to graduate to Java and the kinds of applications you can develop with it. 3. What’s relationship between JavaScript and ECMAScript? ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3. 4. How do you submit a form using Javascript? Use document.forms.submit(); (0 refers to the index of the form – if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on). 5. How do we get JavaScript onto a web page? You can use several different methods of placing javascript in you pages. You can directly add a script element inside the body of page. 1. For example, to add the “last updated line” to your pages, In your page text, add the following: blah, blah, blah, blah, blah. yada, yada, yada. (Note: the first comment, “” finishes the comment. The “//” tells javascript that this is a comment so javascript doesn’t try to interpret the “–>”. If your audience has much older browsers, you should put this comments inside your javascript. If most of your audience has newer browsers, the comments can be omitted. For brevity, in most examples here the comments are not shown. ) The above code will look like this on Javascript enabled browsers, 2. Javascript can be placed inside the element Functions and global variables typically reside inside the element. Default Test Page var myVar = “”; function timer(){setTimeout(‘restart()’,10);} document.onload=timer(); 3. Javascript can be referenced from a separate file Javascript may also a placed in a separate file on the server and referenced from an HTML page. (Don’t use the shorthand ending “). These are typically placed in the element. 6. How to read and write a file using javascript? I/O operations like reading or writing a file is not possible with client-side javascript. However , this can be done by coding a Java applet that reads files for the script. 7. How to detect the operating system on the client machine? In order to detect the operating system on the client machine, the navigator.appVersion string (property) should be used. 8. How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site? JavaScript’s greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for a server program to re-render the page and send it back to the client. For example, consider a top-level navigation panel that has, say, six primary image map links into subsections of the Web site. With only a little bit of scripting, each map area can be instructed to pop up a more detailed list of links to the contents within a subsection whenever the user rolls the cursor atop a map area. With the help of that popup list of links, the user with a scriptable browser can bypass one intermediate menu page. The user without a scriptable browser (or who has disabled JavaScript) will have to drill down through a more traditional and time-consuming path to the desired content. 9. How can JavaScript be used to improve the “look and feel” of a Web site? By the same token, how can JavaScript be used to improve the user interface? On their own, Web pages tend to be lifeless and flat unless you add animated images or more bandwidth-intensive content such as Java applets or other content requiring plug-ins to operate (ShockWave and Flash, for example). Embedding JavaScript into an HTML page can bring the page to life in any number of ways. Perhaps the most visible features built into pages recently with the help of JavaScript are the so-called image rollovers: roll the cursor atop a graphic image and its appearance changes to a highlighted version as a feedback mechanism to let you know precisely what you’re about to click on. But there are less visible yet more powerful enhancements to pages that JavaScript offers. Interactive forms validation is an extremely useful application of JavaScript. While a user is entering data into form fields, scripts can examine the validity of the data–did the user type any letters into a phone number field?, for instance. Without scripting, the user has to submit the form and let a server program (CGI) check the field entry and then report back to the user. This is usually done in a batch mode (the entire form at once), and the extra transactions take a lot of time and server processing power. Interactive validation scripts can check each form field immediately after the user has entered the data, while the information is fresh in the mind. Another helpful example is embedding small data collections into a document that scripts can look up without having to do all the server programming for database access. For instance, a small company could put its entire employee directory on a page that has its own search facility built into the script. You can cram a lot of text data into scripts no larger than an average image file, so it’s not like the user has to wait forever for the data to be downloaded. Other examples abound, such as interactive tree-structure tables of contents. More modern scriptable browsers can be scripted to pre-cache images during the page’s initial download to make them appear lickety-split when needed for image swapping. I’ve even written some multi-screen interactive applications that run entirely on the client, and never talk to the server once everything is downloaded. 10. What are JavaScript types? Number, String, Boolean, Function, Object, Null, Undefined.
JAVASCRIPT Interview Questions 11. How do you convert numbers between different bases in JavaScript? Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt (“3F”, 16); 12. How to create arrays in JavaScript? We can declare an array like this var scripts = new Array(); We can add elements to this array like this scripts = “PHP”; scripts = “ASP”; scripts = “JavaScript”; scripts = “HTML”; Now our array scrips has 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2 . Here is the way to get the third element of an array. document.write(scripts); We also can create an array like this var no_array = new Array(21, 22, 23, 24, 25); 13. How do you target a specific frame from a hyperlink? Include the name of the frame in the target attribute of the hyperlink. >My Page 14. What is a fixed-width table and its advantages? Fixed width tables are rendered by the browser based on the widths of the columns in the first row, resulting in a faster display in case of large tables. Use the CSS style table-layout:fixed to specify a fixed width table. If the table is not specified to be of fixed width, the browser has to wait till all data is downloaded and then infer the best width for each of the columns. This process can be very slow for large tables. 15. Example of using Regular Expressions for syntax checking in JavaScript … var re = new RegExp(“^(&{1,}={1,})*$”); var text = myWidget.value; var OK = re.test(text); if( ! OK ) { alert(“The extra parameters need some work.\r\n Should be something like: \”&a=1&c=4\””); } 16. How to add Buttons in JavaScript? The most basic and ancient use of buttons are the “submit” and “clear”, which appear slightly before the Pleistocene period. Notice when the “GO!” button is pressed it submits itself to itself and appends the name in the URL. Your Name: Another useful approach is to set the “type” to “button” and use the “onclick” event. function displayHero(button) { alert(“Your hero is \””+button.value+”\”.”); } Select a Hero 17. Where are cookies actually stored on the hard disk? This depends on the user’s browser and OS. In the case of Netscape with Windows OS,all the cookies are stored in a single file called cookies.txt c:\Program Files\Netscape\Users\username\cookies.txt In the case of IE,each cookie is stored in a separate file namely [email protected]. c:\Windows\Cookies\[email protected] 18. What can javascript programs do? Generation of HTML pages on-the-fly without accessing the Web server. The user can be given control over the browser like User input validation Simple computations can be performed on the client’s machine The user’s browser, OS, screen size, etc. can be detected Date and Time Handling 19. How to set a HTML document’s background color? document.bgcolor property can be set to any appropriate color. 20. How can JavaScript be used to personalize or tailor a Web site to fit individual users? JavaScript allows a Web page to perform “if-then” kinds of decisions based on browser version, operating system, user input, and, in more recent browsers, details about the screen size in which the browser is running. While a server CGI program can make some of those same kinds of decisions, not everyone has access to or the expertise to create CGI programs. For example, an experienced CGI programmer can examine information about the browser whenever a request for a page is made; thus a server so equipped might serve up one page for Navigator users and a different page for Internet Explorer users. Beyond browser and operating system version, a CGI program can’t know more about the environment. But a JavaScript-enhanced page can instruct the browser to render only certain content based on the browser, operating system, and even the screen size. Scripting can even go further if the page author desires. For example, the author may include a preference screen that lets the user determine the desired background and text color combination. A script can save this information on the client in a well-regulated local file called a cookie. The next time the user comes to the site, scripts in its pages look to the cookie info and render the page in the color combination selected previously. The server is none the wiser, nor does it have to store any visitor-specific information. 21. Are you concerned that older browsers don’t support JavaScript and thus exclude a set of Web users? individual users? Fragmentation of the installed base of browsers will only get worse. By definition, it can never improve unless absolutely everyone on the planet threw away their old browsers and upgraded to the latest gee-whiz versions. But even then, there are plenty of discrepancies between the scriptability of the latest Netscape Navigator and Microsoft Internet Explorer. The situation makes scripting a challenge, especially for newcomers who may not be aware of the limitations of earlier browsers. A lot of effort in my books and ancillary material goes toward helping scripters know what features work in which browsers and how to either workaround limitations in earlier browsers or raise the compatibility common denominator. Designing scripts for a Web site requires making some hard decisions about if, when, and how to implement the advantages scripting offers a page to your audience. For public Web sites, I recommend using scripting in an additive way: let sufficient content stand on its own, but let scriptable browser users receive an enhanced experience, preferably with the same HTML document. 22. What does isNaN function do? Return true if the argument is not a number. 23. What is negative infinity? It’s a number in JavaScript, derived by dividing negative number by zero. 24. In a pop-up browser window, how do you refer to the main browser window that opened it? Use window.opener to refer to the main window from pop-ups. 25. What is the data type of variables of in JavaScript? All variables are of object type in JavaScript. 26. Methods GET and POST in HTML forms – what’s the difference? GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb. POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair. 27. How to write a script for “Select” lists using javascript 1. To remove an item from a list set it to null mySelectObject.options = null; 2. To truncate a list set its length to the maximum size you desire mySelectObject.length = 2; 3. To delete all options in a select object set the length to 0. mySelectObject.leng 28. Text From Your Clipboard? It is true, text you last copied for pasting (copy & paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data to a database on another server. 29. What does the “Access is Denied” IE error mean? The “Access Denied” error in any browser is due to the following reason. A javascript in one window or frame is tries to access another window or frame whose document’s domain is different from the document containing the script. 30. Is a javascript script faster than an ASP script? Yes.Since javascript is a client-side script it does require the web server’s help for its computation,so it is always faster than any server-side script like ASP,PHP,etc.. 31. Are Java and JavaScript the Same? No.java and javascript are two different languages. Java is a powerful object – oriented programming language like C++,C whereas Javascript is a client-side scripting language with some limitations. 32. How to embed javascript in a web page? javascript code can be embedded in a web page between tags 33. What and where are the best JavaScript resources on the Web? The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ , which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain. For interactive help with specific problems, nothing beats the primary JavaScript Usenet newsgroup, comp.lang.javascript. Depending on my work backlog, I answer questions posted there from time to time. Netscape and Microsoft also have vendor-specific developer discussion groups as well as detailed documentation for the scripting and object model implementations. 34. What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage? Browser version incompatibility is the biggest problem. It requires knowing how each scriptable browser version implements its object model. You see, the incompatibility rarely has to do with the core JavaScript language (although there have been improvements to the language over time); the bulk of incompatibility issues have to do with the object models that each browser version implements. For example, scripters who started out with Navigator 3 implemented the image rollover because it looked cool. But they were dismayed to find out that the image object wasn’t scriptable in Internet Explorer 3 or Navigator 2. While there are easy workarounds to make this feature work on newer browsers without disturbing older ones, it was a painful learning experience for many. The second biggest can of worms is scripting connections between multiple windows. A lot of scripters like to have little windows pop up with navigation bars or some such gizmos. But the object models, especially in the older browser versions, don’t make it easy to work with these windows the minute you put a user in front of them–users who can manually close windows or change their stacking order. More recently, a glitch in some uninstall routines for Windows 95 applications can disturb vital parts of the system Registry that Internet Explorer 4 requires for managing multiple windows. A scripter can’t work around this problem, because it’s not possible to detect the problem in a user’s machine. I tend to avoid multiple windows that interact with each other. I think a lot of inexperienced Web surfers can also get confused by them. 35. What boolean operators does JavaScript support? &&, || and ! 36. What does “1”+2+4 evaluate to? Since 1 is a string, everything is a string, so the result is 124. 37. What are the ways to emit client-side JavaScript from server-side code in ASP.NET? The Page object in ASP.NET has two methods that allow emitting of client-side JavaScript: RegisterClientScriptBlock and RegisterStartupScript. Example usage: Page.RegisterClientScriptBlock(“ScriptKey”, “” + “function TestFn() { alert(‘Clients-side JavaScript’); }”); Page.RegisterStartupScript(“ScriptKey”, “” + “function TestFn() { alert(‘Clients-side JavaScript’); }”); ScriptKey is used to suppress the same JavaScript from being emitted more than once. Multiple calls to RegisterClientScriptBlock or RegisterStartupScript with the same value of ScriptKey emit the script only once, on the first call. 38. What is the difference between RegisterClientScriptBlock and RegisterStartupScript? RegisterClientScriptBlock emits the JavaScript just after the opening tag. RegisterStartupScript emits the JavaScript at the bottom of the ASP.NET page just before the closing tag. 39. What is the difference between a web-garden and a web-farm? Web-garden – An IIS6.0 feature where you can configure an application pool as a web-garden and also specify the number of worker processes for that pool. It can help improve performance in some cases. Web-farm – a general term referring to a cluster of physically separate machines, each running a web-server for scalability and performance (contrast this with web-garden which refers to multiple processes on one single physical machine). 40. How to get the contents of an input box using Javascript? Use the “value” property. var myValue = window.document.getElementById(“MyTextBox”).value; 41. How to determine the state of a checkbox using Javascript? var checkedP = window.document.getElementById(“myCheckBox”).checked; 42. How to set the focus in an element using Javascript? function setFocus() { if(focusElement != null) { document.forms.elements.focus(); } } 43. How to access an external javascript file that is stored externally and not embedded? This can be achieved by using the following tag between head tags or between body tags. How to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed. 44. What is the difference between an alert box and a confirmation box? An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel. 45. What is a prompt box? A prompt box allows the user to enter input by providing a text box. 46. Can javascript code be broken in different lines? Breaking is possible within a string statement by using a backslash \ at the end but not within any other javascript statement. that is , document.write(“Hello \ world”); is possible but not document.write \ (“hello world”); 47. Taking a developer’s perspective, do you think that that JavaScript is easy to learn and use? One of the reasons JavaScript has the word “script” in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you. For example, JavaScript is a loosely typed language, which means that a variable doesn’t care if it’s holding a string, a number, or a reference to an object; the same variable can even change what type of data it holds while a script runs. The other part of JavaScript implementation in browsers that makes it easier to learn is that most of the objects you script are pre-defined for the author, and they largely represent physical things you can see on a page: a text box, an image, and so on. It’s easier to say, “OK, these are the things I’m working with and I’ll use scripting to make them do such and such,” instead of having to dream up the user interface, conceive of and code objects, and handle the interaction between objects and users. With scripting, you tend to write a _lot_ less code. 48. What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst? The best sites are the ones that use JavaScript so transparently, that I’m not aware that there is any scripting on the page. The worst sites are those that try to impress me with how much scripting is on the page. 49. How about 2+5+”8″? Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result. 50. What is the difference between SessionState and ViewState? ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application. 51. What does the EnableViewStateMac setting in an aspx page do? Setting EnableViewStateMac=true is a security measure that allows ASP.NET to ensure that the viewstate for a page has not been tampered with. If on Postback, the ASP.NET framework detects that there has been a change in the value of viewstate that was sent to the browser, it raises an error – Validation of viewstate MAC failed. Use to set it to true (the default value, if this attribute is not specified is also true) in an aspx page. 52. How to Accessing Elements using javascript? To do something interesting with HTML elements, we must first be able to uniquely identify which element we want. In the example We can use the “getElementById” method (which is generally preferred) document.getElementById(“useless”).style.color = “red”; or we can use the older hierarchical navigation method, document.forms.mybutton.style.color = “blue”; Notice that this uses the “name” attribute of the element to locate it. # Example of Accessing Elements in a DOM. function showStatus() { var selectWidget = document.forms.beerForm.elements; var myValue = selectWidget.options.value; alert(‘You drank a \”‘+ myValue +”\””); return true; } Select Beer Heineken Amstel Light Corona Corona Light Tecate 53. What looping structures are there in JavaScript? for, while, do-while loops, but no foreach. 54. To put a “close window” link on a page ? Close 55. How to hide javascript code from old browsers that dont run it? Use the below specified style of comments or Use the some html code tags and code the display html statements between these and this will appear on the page if the browser does not support javascript 56. How to comment javascript code? Use // for line comments and /* */ for block comments 57. Name the numeric constants representing max,min values Number.MAX_VALUE Number.MIN_VALUE 58. What does javascript null mean? The null value is a unique value representing no value or no object. It implies no object,or null string,no valid boolean value,no number and no array object. 59. How do you create a new object in JavaScript? var obj = new Object(); or var obj = {}; 60. How to read a Cookie using JavaScript? Reading a cookie is just as simple as writing one, because the value of the document.cookie object is the cookie. So you can use this string whenever you want to access the cookie. The document.cookie string will keep a list of name = value pairs separated by semicolons, where name is the name of a cookie and value is its string value. You can use strings' split() function to break the string into key and values. 61. How to delete a Cookie using JavaScript? Sometimes you will want to delete a cookie so that subsequent attempts to read the cookie return nothing. To do this, you just need to set the expiration date to a time in the past. 62. What is this keyword? It refers to the current object. 63. What does the term sticky session mean in a web-farm scenario? Why would you use a sticky session? What is the potential disadvantage of using a sticky session? Sticky session refers to the feature of many commercial load balancing solutions for web-farms to route the requests for a particular session to the same physical machine that serviced the first request for that session. This is mainly used to ensure that a in-proc session is not lost as a result of requests for a session being routed to different servers. Since requests for a user are always routed to the same machine that first served the request for that session, sticky sessions can cause uneven load distribution across servers. 64. You have an ASP.NET web application running on a web-farm that does not use sticky sessions – so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message Validation of viewstate MAC failed. What could be one reason that is causing this error? The most common reason for this error is that the the machinekey value in machine.config is different for each server. As a result, viewstate encoded by one machine cannot be decoded by another. To rectify this, edit the machine.config file on each server in the web-farm to have the same value for machinekey. 65. To set all checkboxes to true using JavaScript? //select all input tags function SelectAll() { var checkboxes = document.getElementsByTagName(“input”); for(i=0;i tag. Old browsers will now treat this JavaScript code as a long HTML comment. While, a browser that supports JavaScript, will take the “” as one-line comments. 86.How to create an Object in JavaScript ? var obj = new Object(); var ob = {}; 87.Basic methods for opening a PopUp window using Javascript? There are 2 different simple ways using javascript. they are 1) Using Window.Open() and 2) Using Window.showModalDialog() The Syntax for using these methods are => Window.Open(URL,WindowName,Window Features) Sample example: window.open ("http://www.atoztarget.com","mywindow","status=1,toolbar=1"); => window.showModalDialog(URL,WindowName,ModalDialog Features) Sample Example: window.showModalDialog("http://www.dotnetfunda.com", "mywindow","dialogWidth:400px;dialogHeight:395px"); 88.What is JSON? JSON is nothing but a JavaScript Object Notation . It is language independent and derived from Java Script. This is a LightWeight scripting language designed for data interchange over a network. Basically this is used for data serialization and data transmission which helps to transfer data between the server and the web application. 89.How can you detect the Client Operating System using Javascript? just type this command in a .html file alert(window.navigator.appVersion); 90.What is the data type of variables in JavaScript? Javascript is a weakly typed language:It does not use int, string, DateTime etc as the datatype with the variables declaration as we do in c#. variables are declared using the var keyword which can accept any data. 91.What is negative infinity? It’s a number in JavaScript, derived by dividing negative number by zero. Code snippet var a=-45; alert(a/0); output: -Infinity 92.if 2 methods have same name and same number of parameters, which one will be executed first? The second method will be executed first Code snippet. function demo(s) { alert("first"+"---"+s); } function demo(s) { alert("Second"+"--"+s); } demo("javascript"); demo("jscript"); demo("jp"); output: //In this example, the function with alert("Second"+"---"+s); statement will //be executed 3 times, while the first function will not execute at all. 93.Difference between undefined and undeclared variables. Undefined variables are those that are not assigned any value but declared in the program. if we try to read the value, an error message "undefined" is displayed. undeclared variables are those that are not declared in the program . if we try to read their values gives runtime error. But if undeclared variables are assigned some value then implicit declaration is done . example: //a is undefined variable var a; alert(a); //b is undeclared variable alert("hello"+"--"+b); A:-undefined: B:-will also be undefined but that error message can be seen by clicking in browser status bar: if some value is assigned to b, then it will be displayed in the output. 94.Difference Json Arrary Vs Json Object ? JSONArray A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with commas separating the values. JSONObject A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names. {"bindings": }; 95.What is the difference of "setTimeout" function and setInterval functions in Javascript setTimeout is only execute the function after the defined time in milleseconds, its execute only one time. setInterval, will call the function in each time interval. 96.What is the difference between the below two statements:- (1) var myname = "Akiii"; (2) myname = "Akiii"; Both the above two statements are same. In javascript, even if you don't declare a "var" keyword, it is automatically added. Note:- It is always good to use "var" to declare any variable in javascript. It makes the code cleaner and readable. 97.What data type javascript supports? Javascript supports only object data type. Example var variablename; //var is an object 98.What is isNaN in javascript? isNaN is a function, it returns true if the argument is not a number. Example: var a="text"; var b=1234; document.write(isNaN(a)) //it will return true document.write(isNaN(b)) //returns false 99.How will you create new object in javascript? In object variable, you can pass any value like stirng, integer. var obj=new Object(); obj="my string"; document.write(obj); 100.How do you create array in javascript? var arr=new Array(); arr="dot"; arr="net"; arr="funda"; document.write(arr + " " + arr + " " + arr); 101.Write a way by which you can do something on the close of the window ? call onUnload on the body tag and write your javascript code there e.g: Read the full article
0 notes
Link
Learn and Understand Regular Expression ##elearning ##FreeUdemyCourses #Expression #Learn #Regular #Understand Learn and Understand Regular Expression Welcome to "Learn and Understand Regular Expression(REGEX)" course This is a course of regular expressions. When I start leaning regular expression I found it really difficult to understand. I think regular expression is a pain for beginners. I'm apologies that and designed a course to help you out. If you are not understanding regular expressions(scratching your head) then just enroll this course and see how easy it is. You are going to be learn: Introduction Introduction to regular expressions Metacharacters Literal characters, flag modifiers, dot metacharacter, anchors, escaping metacharacters and word boundaries Character Classes Character classes, negate character classes, shorthands character classes Repetitions Plus (+) quantifiers, asterisk (*) quantifiers, controlling repetitions, greediness and laziness Grouping and Backreferencing Grouping, capturing and backreferencing, non capturing group, alternation and nested alternation Lookaround - lookahead and lookbehind Lookaround and assertions, positive lookahead, negative lookahead, positive lookbehind and negative lookbehind Solving real world problems in PHP using REGEX Username validation, email validation, password validation, coupon code ,date validation, zip code validation You nothings to lose because 30 days money back guarantee. See you inside! Who this course is for: Who wants to learn regular expressions clearly Who has frustrated to learn regular expressions Students looking for a simple way to learn regular expressions 👉 Activate Udemy Coupon 👈 Free Tutorials Udemy Review Real Discount Udemy Free Courses Udemy Coupon Udemy Francais Coupon Udemy gratuit Coursera and Edx ELearningFree Course Free Online Training Udemy Udemy Free Coupons Udemy Free Discount Coupons Udemy Online Course Udemy Online Training 100% FREE Udemy Discount Coupons https://www.couponudemy.com/blog/learn-and-understand-regular-expression/
0 notes