Summary of common problems in PHP

zhaozj2021-02-16  53

Summary of some common problems in PHP ***************************************************************** *******************

Summary to progress?

Big cabbage core

*********************************************************** ****************

1: Why can't I get a variable?

I didn't get any value when I output $ Name when I output $ Name when I output $ NAME?

Register_global defaults in the version after php4.2 is OFF If you want to get the variable submitted from another page:

Method 1: Find the register_global in php.ini, set it to ON. Method: Put this extract ($ _ post) in front of the received web page; ($ _ get); (note extract ($ _ session) There is a session_start ()). Method 3: A read variable $ A = $ _ get ["a"]; $ b = $ _ post ["b"], etc., this method is trouble, but is safe.

2: Debug your program

You must know what a variable must be known at runtime. I did this, build a file debug.php, the content is as follows:

PHP code: ----------------------------------------------- ---------------------------------

";

Echo "This page" The _GET variable is: "; Print_R ($ _ get);

Echo "The _post variables obtained on this page are:"; Print_R ($ _ POST);

Echo "The _cookie variables available on this page are:"; Print_R ($ _ cookie);

Echo "This page" _Session variables are: "; Print_R ($ _ session); Echo" ";?>>

-------------------------------------------------- ------------------------------

Then set in php.ini: include_path = "C: / PHP" and place debug.php in this folder, and you can include this file in each web page, view the obtained variable name and value.

3: How to use session

Anyone is related to session, you must call the function session_start ();

Paying for the session is very simple, such as:

PHP code: ----------------------------------------------- ---------------------------------

-------------------------------------------------- ------------------------------

After PHP4.2, you can pay for the session:

PHP code: ----------------------------------------------- ---------------------------------

-------------------------------------------------- ------------------------------

Cancel session can be like this:

PHP code: ----------------------------------------------- ---------------------------------

>

-------------------------------------------------- ------------------------------

Cancel a session variable has bugs above PHP4.2 or more.

note:

1: There is no output before calling session_start (). For example, the following is wrong. =============================== =========== 1 line 2 line ====== =====================================

Tip 1:

Any "....... HEADERS ALREADY SENT ..." , The same cause of error)

Tip 2:

If your session_start () is placed in a loop statement, and it is difficult to determine where to output information to the browser, you can use the following method: 1 line ........ Here is your program ...

2: What is wrong?

Warning: session_start (): Open (/ tmp / sess_7d190aa36b4c5ec13a5c1649cc2da23f, o_rdwr) failed: .... Because you don't specify the storage path of the Session file.

Solution: (1) Open php.ini in the C disk, find session.save_path, modified to session.save_path = "c: / tmp"

4: Why do I send variables to another web page, I only get the first half, and all lost in space.

PHP code: ----------------------------------------------- ---------------------------------

--------------------------------------------- -----------------------------------

Receive.php content:

PHP code: ----------------------------------------------- ---------------------------------

"; echo $ _get ["name"]; ECHO "";?>

-------------------------------------------------- ------------------------------

The correct way is:

PHP code: ----------------------------------------------- ---------------------------------

-------------------------------------------------- ------------------------------

You don't need to use Urldecode () in the receiving page, and the variable will be automatically encoded.

5: How to intercept the specified length of Chinese characters without the end of "?>", Exceeding the part to "..." instead

In general, the variables to be intercepted come from mysql, first to ensure that the length is long enough, generally CHAR (200), can keep 100 Chinese characters, including punctuation.

PHP code: ----------------------------------------------- ---------------------------------

= $ LEN) Break; IF (Substr ($ Str, $ I, 1))> 0xA0) {IF ($ Clen> = $ Start) $ TMPSTR. = Substr ($ Str, $ I , 2); $ I ;} else {IF ($ Clen> = $ start) $ TMPSTR. = Substr ($ Str, $ I, 1);}}

Return $ TMPSTR;} Function Showsh ($ STR, $ LEN) {$ Tempstr = CSUBSTR ($ STR, 0, $ LEN); if ($ STR <> $ TEMPSTR) $ TEMPSTR. = "..."; // To end, you can modify it here.

Return $ TEMPSTR;} --------------------------------------------- -----------------------------------

6: Specify your SQL statement

In the form, in front of the field, add "` ", this will not appear errors because of misuse keywords, of course, I don't recommend you to use keywords.

For example $ sql = "Insert Into` xltxlm`, `author`,`, `date`) Values ​​('XLTXLM', 'Use`', 1, 'Criterion Your SQL String' , '2003-07-11 00:00:00') "

"` "How to enter? On the Tab button.

7: How to make the string of the HTML / PHP format are not interpreted, but is displayed as an original

PHP code: ----------------------------------------------- ---------------------------------

PHP "; echo "is explained:" $ Str. "
processed:"; Echo Htmlentities (NL2BR ($ Str));? >

-------------------------------------------------- ------------------------------

8: How to get the variable value outside the function in the function

PHP code: ----------------------------------------------- ---------------------------------

>

-------------------------------------------------- ------------------------------

9: How do I know what function is supported by default?

PHP code: ----------------------------------------------- ---------------------------------

"; echo "here display all functions supported by the system, and self-qualified function PHP / N"; Print_R ($ ARR); ECHO "";?> ---------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------

10: How to compare two dates a few days

PHP code: ----------------------------------------------- ---------------------------------

--------------------------------- -----------------------------------------------

11: Why after I upgrade PHP, the original program appears full screen: undefined variable:

This is the meaning of warning, because the variable is not defined. Open php.ini, find the bottom ERROR_REPORTING, modify to Error_Reporting = E_ALL & ~ E_NOTICE

For PARSE ERROR Error Error_Reporting (0) Can't turn off. If you want to close any error prompts, open php.ini, find Display_ERRORS, set to display_errors = off. Any error will not be prompted later.

What is Error_Reporting?

12: I want to add a file in front of each file, but in the end. But a very troublesome added

1: Open the php.ini file settings include_path = "C:"

2: Write two files auto_prepend_file.php and auto_append_file.php Save in the C drive, they will automatically attach to the head and tail of each PHP file.

3: Find in php.ini: Automatically Add Files Before or After any PHP Document.Auto_prepend_file = auto_prepend_file.php; It is attached to the head auto_APpend_file = auto_append_file.php;

After you will be equivalent to each PHP file

PHP code: ----------------------------------------------- ---------------------------------

....... / / Here is your program

INCLUDE "auto_append_file.php";?>

-------------------------------------------------- ------------------------------

13: How to use the PHP upload file

PHP code: ----------------------------------------------- ---------------------------------

Upload file form </ title> </ head> <body> <form encType = "Multipart / Form-data" action = "" "" Method = "POST"> Select file: <br > <input name = "UPLOAD_FILE" type = "file"> <BR> <input type = "submit" value = "Upload File"> </ form> </ body> </ html> <$ upload_file = $ _ files ['UPLOAD_FILE'] ['TMP_NAME']; $ upload_file_name = $ _ files ['Upload_File'] ['Name'];</p> <p>IF ($ upload_file) {$ file_size_max = 1000 * 1000; // 1m Limit file Upload Maximum Capacity (BYTES) $ store_dir = "d: //" Upload file storage position $ accept_overwrite = 1; // Whether to allow overwriting Same file // Check file size if ($ upload_file_size> $ file_size_max) {echo "Sorry, your file capacity is greater than specified"; exit;}</p> <p>// Check the documentation of the same file name in the read and write file IF (file_exists ($ store_dir. $ Upload_file_name) {echo "; exit;</p> <p>// Copy the file to the specified directory IF (! Move_uploaded_file ($ upload_file, $ store_dir. $ Upload_file_name)) {echo "copy file failed"; exit;</p> <p>}</p> <p>Echo "<p> You uploaded the file:"; Echo $ _files ['UPLOAD_FILE'] ['Name']; echo "<br>"; // The original name of the client machine file.</p> <p>The MIME type of the echo file is: "; echo $ _files ['UPLOAD_FILE'] ['type']; // file MIME type, you need to provide this information for the information, such as" image / gif ". Echo "<br>";</p> <p>Echo "Upload File Size:"; Echo $ _Files ['UPLOAD_FILE'] ['size']; // The size of the file has been uploaded, the unit is byte. Echo "<br>";</p> <p>The echo "file is uploaded after being temporarily stored as:"; Echo $ _files ['UPLOAD_FILE'] ['TMP_NAME']; // The file is stored in the server after being uploaded. Echo "<br>";</p> <p>$ Erroe = $ _ files ['UPLOAD_FILE'] ['Error']; Switch ($ Erroe) {Case 0: Echo "Upload Success"; Break; Case 1: Echo "Uploaded files exceed php.ini UPLOAD_MAX_FILESIZE Option Limit The value. "; Break; Case 2: Echo" Uploaded file size exceeds the value specified by the max_file_size option in the HTML form. "; Break; Case 3: Echo" file only partially uploaded "; Break; Case 4: Echo" No file is uploaded "; Break;}?> --------------------------------------- -----------------------------------------</p> <p>14: How to configure a GD library</p> <p>Below is my configuration process 1: Use a dos command (you can also manually, copy all DLL files in the DLLS folder to the System32 directory) COPY C: / PHP / DLLS / *. DLL C: / Windows / System32 / 2: Open php.ini settings EXTENSION_DIR = "C: / PHP / EXTENSIONS /"; 3: Extension = php_gd2.dll; remove the comma in front of Extension, if there is no php_gd2.dll, php_gd.dll is the same, to ensure that this file does C: / php/extensions/php_gd2.dll4: Run the following program for testing</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? phpob_end_flush (); // Note that you cannot output any information to your browser until you set whether auto_prepend_file.head ("content-type: image / png"); $ = @ImageCreate (200, 100 ("Unable to create images"); $ background_color = imagecolorallocate ($ IM, 0, 0, 0); $ text_color = imagecolorallocate ($ IM, 230, 140, 150); ImageString ($ IM, 3, 30, 50, "a Simple Text String", $ text_color; imagepng ($ IM);?></p> <p>-------------------------------------------------- ------------------------------</p> <p>Click here to view the result</p> <p>15: What is UBB code</p> <p>The UBB code is a variant of HTML. It is a special TAG that uses this BULLETIN Board (a foreign BBS program, there are also many places in China). Even if you are forbidden, you can use Ubbcode? Maybe. Maybe Do you prefer to use ubbcode? Instead of HTML, even if the forum allows you to use HTML, because the code is less and safer.</p> <p>Q3boy's UBB has an example, you can run test directly</p> <p>16: I want to modify the MySQL user, password</p> <p>First, in most cases, modifying mysql is required to have root permissions in MySQL, so general users cannot change the password unless the administrator is requested.</p> <p>Methods One using phpmyadmin, this is the easiest, modify the User table of the MySQL library, but don't forget to use the Password function.</p> <p>Method 2 uses mysqladmin, which is a special case of the previous declaration. Mysqladmin -u root -p password mypasswd Enter this command, you need to enter the original password of the root, and then the root's password will be changed to mypasswd. Change the root in the command to your username, you can change your own password. Of course, if your mysqladmin connection is not mysql server, or you have no way to execute mysqladmin, then this method is invalid. And mysqladmin cannot empty your password. The following method is used in the MySQL prompt, and must have a mysql root permission: Method 3 mysql> INSERT INTO mysql.user (Host, User, Password) Values ​​('%', 'Jeffrey', Password ('Biscuit' )))); Mysql> Flush privileges is exactly that this is increasing a user, the username is Jeffrey, the password is Biscuit. There is this example in the "MySQL Chinese Reference Manual", so I will write it. Note To use the Password function, then use Flush Privileges.</p> <p>Methods 4 and Methods, like three, just use the Replace statement mysql> Replace Into mysql.user (Host, User, Password) VALUES ('%', 'Jeffrey', Password ('Biscuit')); MySQL> Flush Privileges</p> <p>Method 5 Use the set password statement, mysql> set password for jeffrey @ "%" = password ('biscuit'); you must also use the password () function, but do not need to use Flush Privileges.</p> <p>Method 6 Use Grant ... Identified by statement mysql> grant usage on *. * To jeffrey @ "%" Identified by 'biscuit'; here the password () function is unnecessary, nor does it need to use Flush Privileges.</p> <p>Note: Password () [is not] The password encryption is applied to the same method encrypted at UNIX password.</p> <p>17: I want to know which website is connected to this page.</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? php // must enter the output Echo $ _server ['http_referer'] by super connection.</p> <p>-------------------------------------------------- ------------------------------</p> <p>18: Data is placed in the database and take it out to display what to pay attention to on the page</p> <p>$ Str = addslashes ($ STR); $ SQL = "INSERT INTO` Tab` (`$ str ') (' $ str '); out of the warehouse $ str = stripslashes ($ STR); Show Time $ Str = HTMLSpecialchars (NL2BR ($ Str));</p> <p>19: How to read the current address bar information</p> <p>PHP code: ----------------------------------------------- --------------------------------- <? PHP $ S = "http: // {$ _server [http_host ']}: {$ _ Server ["server_port"]} {$ _ server [' script_name ']} "; $ se ='; foreach ($ _get as $ key => $ value) {$ SE. = $ key. "=" $ value. "&"; "/( (.*) (" /( (.*)); $ 1 ", $ SE); $ SE? $ SE ="? "$ SE:" "; Echo $ s." $ se ";?> ------------------------------------ --------------------------------------------</p> <p>20: I click the back button, why do you fill in something before?</p> <p>This is because you use the session. Solution:</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? php session_cache_limiter ('private, must-revALIDATE'); session_start (); ...........................</p> <p>-------------------------------------------------- ------------------------------</p> <p>21: How to display IP addresses in the picture</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? Header ("Content-Type: Image / PNG"); $ IMG = ImageCreate (180, 50); $ IP = $ _SERVER ['Remote_addr']; ImageColortransparent ($ IMG, $ BGCOLOR); $ bgcolor = imagecolorlocate $ IMG, 0x2C, 0x6D, 0xAF); // Background Color $ shadow = ImageColoralLocate ($ IMG, 250, 0); // Shadow Color $ TEXTCOLOR = ImageColoralLocate ($ IMG, Oxff, Oxff, Oxff); // Font Color ImageTfText ($ IMG, 10, 78, 30, $ Shadow, "D: /Windows/fonts/tahoma.ttf", $ IP); // Display Background ImageTfText ($ IMG, 10, 0, 25, 28, $ textColor, "D: /Windows/fonts/tahoma.ttf", "Your IP IS". $ IP); // Displays iPImagePng; ImageCreateFromPng ($ IMG); ImageDestroy ;? ></p> <p>-------------------------------------------------- ------------------------------</p> <p>22: How to get the real IP of the user</p> <p>PHP code: ----------------------------------------------- --------------------------------- <? Function iptype1 () {ix (Getenv ("http_client_ip")) { return getenv ( "HTTP_CLIENT_IP");} else {return "none";}} function iptype2 () {if (getenv ( "HTTP_X_FORWARDED_FOR")) {return getenv ( "HTTP_X_FORWARDED_FOR");} else {return "none";} } Function iptype3 () {if ("Remote_ADDR")) {RETURN GETENV ("remote_addr");} else {return "none";}} function IP () {$ IP1 = iptype1 (); $ ip2 = iptype2 (); $ Ip3 = iptype3 (); if (ISSET ($ IP1) && $ IP1! = "None" && $ ip1! = "Unknown") {RETURN $ IP1;} elseif (isset ($ IP2) && $ IP2 ! = "NONE" && $ IP2! = "Unknown") {RETURN $ IP2;} elseif (isset ($ IP3) && $ IP3! = "NONE" && $ IP3! = "Unknown") {Return $ IP3;} Else {return "none";}}</p> <p>Echo ip ();?> ------------------------------------------- -------------------------------------</p> <p>23: How to read all records within three days from the database</p> <p>First, there must be a DateTime field record time in the form, the format is '2003-7-15 16:50:00'</p> <p>Select * from `xltxlm` WHERE TO_DAYS (now ()) - to_days (` Date`) <= 3;</p> <p>24: How to Remote Link MySQL Database</p> <p>In the increase of the user's MySQL table, there is a Host field, modified to "%", or specify the IP address that allows the connection, so you can call remotely.</p> <p>$ LINK = mysql_connect ("192.168.1.80:3306", "root", "");</p> <p>25: How to use it</p> <p>Click here for special characters in the regular expression</p> <p>26: After using Apache, the home page is garbled.</p> <p>Method 1: AddDefaultCharset ISO-8859-1 is changed to AddDefaultCharset Off</p> <p>Method 2: AdddefaultCharset GB2312 ============================================= =========== TIP: When the code is passed, GB2312 will be explained into ?????? Change this will not be GB2312</p> <p>============================================================================================================================================================================================================= ======</p> <p>10: How to compare two dates a few days, (simpler algorithm)</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? PHP $ DATE_1 = "2003-7-15"; // can also be: $ DATE_1 = "2003-7-15 23:29:14"; $ DATE_2 = "1982-10-1"; $ d1 = Strtotime ($ DATE_1); $ D2 = STRTOTIME ($ DATE_2); $ Days = Round (($ D1- $ D2) / 3600/24); echo "Even the game has been struggling $ days day ^ ^";?>>></p> <p>-------------------------------------------------- ------------------------------</p> <p>27: Why is single quotes, double quotes becomes ('/ ")</p> <p>Workaround: Method 1: Setting in php.ini: Magic_QUOTES_GPC = OFF Method 2: $ Str = Stripcslashes ($ STR)</p> <p>28: How to make the program have been running, not more than 30 seconds</p> <p>SET_TIME_LIMIT (60) // The longest runtime one minute set_time_limit (0) // runs to the program, or stop manual</p> <p>29: Calculate the current online number</p> <p>Example 1: Implementation with text</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? php // You have to read and write permission // This program can be run directly, the first error, you can have $ online_log = "count.dat"; // Save the number of files, $ timeout = 30 No Actions in seconds, think that the drop is $ entries = file ($ online_log);</p> <p>$ TEMP = array ();</p> <p>For ($ I = 0; $ I <entry); $ I ) {$ entry = evtern (",", TRIM ($ Entries [$ I])); if (($ Entry [0]! = GetENV ('Remote_addr') && ($ Entry [1]> Time ())) {Array_Push ($ TEMP, $ Entry [0]. ",". $ entry [1]. "////// Remove other viewers' information and remove the timeshooter, save the $ TEMP}} Array_Push ($ TEMP, GETENV ('Remote_Addr'). "," () ($ TIMEOUT)). "/ N") ; // Update the viewer's time $ users_online = count ($ TEMP); // Calculate the number of online people</p> <p>$ entries = iMPLODE ("", $ TEMP); // Write file $ fp = fopen ($ online_log, "w"); flock ($ fp, lock_ex); // flock () cannot be in NFS and some other Network file system works normally FPUTS ($ FP, $ Entries); FLOCK ($ FP, LOCK_UN); Fclose ($ FP);</p> <p>Echo "currently there". $ usrs_online. "People Online";</p> <p>?> --------------------------------------------------------------------------------------------- --------------------------------</p> <p>Example 2: Implement online users with databases</p> <p>30: What is template, how to use</p> <p>Here are a few articles about templates</p> <p>I am using the PHPLIB Template is the use of several functions.</p> <p>$ T-> Set_file ("Casual Definition", "Template File .tpl");</p> <p>$ T-> set_block ("in set_file", "<! - From Template ->", "Casual Definition");</p> <p>$ T-> PARSE ("Defined in Set_Block", "" From Template -> ", TRUE);</p> <p>$ T-> PARSE ("Casual Output", "Defined in Set_File");</p> <p>Setting the loop format is:</p> <p><! - (more than one space) Begin $ handle (more than one space) -></p> <p>How to generate a template to a static page</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><? php // Use phplib template here ...................... $ TPL-> PARSE ("Output", "HTML"); $ OTPUT = $ TPL-> GET ("Output"); // $ OUTPUT is the content of the entire web page</p> <p>Function WFile ($ file, $ mode = 'w') {$ oldmask = umask (0); $ fp = fopen ($ file, $ mode); if (! $ fp) returnaf false; fwrite ($ FP) $ content); fclose ($ fp); umask; return true;} // Write WFile ($ file, $ output); Header ("Location: $ file"); // Redirect To the generated web page}?> ----------------------------------------- ------------------------------------- PHPLIB Download Address Smarty Download</p> <p>31: How to use PHP explanation characters</p> <p>For example: input 2 2 * (1 2), automatic output 8 can use EVAL functions</p> <p>PHP code: ----------------------------------------------- ---------------------------------</p> <p><form method = post action = "> <input type =" text "name =" str "> <input type =" submit "> </ form> <? php $ str = $ _ post ['str']; evAl ("/ $ o = $ Str;"); Echo "$ O";?></p> <p>-------------------------------------------------- ------------------------------</p> <p>In addition, this function must be particularly careful !! If someone enters Format: D: What is the result?</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-21344.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="21344" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Ts_2F4WNMiFIRqcmLS2M1DpnFoekyQV_2FDgY0iHPcJlXlKv8BCT08H29QyILJRq6JRUlOC9ShqrddTUt5pyfXiA7Q_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>